Python Script works on PC but not on Raspberrypi

August 27, 2024, 01:06

zemangofur

Hey guys so for some reason the python file i'm trying to run only works on my pc but not on my raspberry pi, i've fixed some issues, but there is one i got no idea about
py
data = {
                        "sample": "some sample message"
                }
with open("./file.json", "w") as outfile:
  json.dump(data, outfile)              
for some reason this just does not work, ignore that some stuff is weirdly out of place, it's not like that in the file, it just happened because i copied it over

illegitimate_egg

are you running the same python version?

zemangofur

I'm using a Raspberry pi 4b, with raspberrypi os lite

zemangofur

on my pi it's 3.11.2 and on my pc it's 3.11.4

illegitimate_egg

hm

zemangofur

only the json writing doesn't work

zemangofur

i am so stupid, i just had to run it as sudo

akazaa96

i dont think it has anything to do with the python version, does ./file.json file exists in the folder that you are running it on?

oops.se

Read the last line before your and there is the answer!