Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5394

Python • Program that works in windows not working on pi

$
0
0
So I made a program in windows as it gets bit laggy using realvnc to program with. I thought everything would be fine however when I tried to run my program on my raspberry pi 4b I got this error:

Code:

Error retrieving balance for wvzack: Expecting value: line 1 column 1 (char 0)
Here is the code in requests.py that it is happening on:

Code:

@client.requestdef get_balance():    try:        balance = main.get_value(client.get_requester())        formatted_message = f"You have {balance} dollar(s)"        return balance    except Exception as e:        print(f"Error retrieving balance for {client.get_requester()}: {e}")        return "Error retrieving balance. Check the Python console for details."
and in main.py:

Code:

def read_file():    f = open("data.txt", "r")    file_contents = f.read()    f.close()    return(file_contents)def get_value(username):    data = json.loads(read_file())    print(f"Loaded data: {data}")  # Print the loaded data dictionary    if data.get(username) == None:        add_save(username, startmoney)    else:        print(f"Found user: {username}")  # Print if user exists    return data.get(username)
This code works perfectly in windows.

Thanks!

Statistics: Posted by wvzack — Sun Jun 02, 2024 11:49 pm — Replies 0 — Views 8



Viewing all articles
Browse latest Browse all 5394

Latest Images

Trending Articles



Latest Images