I'm trying to set up my Raspberry Pi to automatically run a Python script that uses OpenCV right after it starts up. I've placed the script in a bash file that changes to the correct directory and then launches the Python script. I added this line to my .bashrc file: "lxterminal -e /home/pi/Documents/test.sh". The script runs, but I'm getting an error message that says "qt.qpa.xcb could not connect". It's odd because the script works perfectly when I run it manually from the terminal. Can anyone help me figure out what's going wrong?
2 Answers
Another thing to consider might be the timing of your script execution. The desktop environment could still be initializing when your script tries to run. You could try putting a delay in your bash script to give it a little extra time to start up the GUI before executing the Python script.
It sounds like there might be an X11 issue. When you start the script manually, is the X11 environment fully running? The error "qt.qpa.xcb" usually means it can't reach the X11 server. This can happen if the script tries to run before the desktop environment is fully loaded during boot.
I checked, and yes, X11 is up and running when I execute the script manually. Plus, after my Pi starts up, a terminal pops up on the desktop and runs the script too, so I know X11 is active.