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

Beginners • Re: Auto Run Python script error xdg_runtime_dir not set in the environment

$
0
0
Same error. This error doesn't happen when you ssh into the RPi and run it, correct?
It appears the python service you are starting is starting out of order, or the required service(s) haven't finished initializing.
At least one error appears to be the sound service. My guess is the "pygame.init()" didn't detect a sound service, so it did not initialize the mixer.

I cheat. I don't know what services pygame requires to initialize the sound mixer. I found if, in your case, the code sleeps a couple seconds before calling "pygame.init()", the services assigning the environment variable and the sound may finish initializing. Just a thought.

Code:

# import stuffimport pygamesleep(5)pygame.init()# rest of your code

Statistics: Posted by SurferTim — Sat Nov 02, 2024 10:38 am



Viewing all articles
Browse latest Browse all 8013

Trending Articles