I have searched this problem online but could not resolve it. Excuse my inexperience. I am trying to run a python script on startup which uses PyQt5 library to create a window. I am using a raspberry pi 3 model b+, and raspbian buster with lxde. I wrote a shell script as follows:
#! /bin/bash
sleep 10
python3 /home/pi/Desktop/workfolder/mainwindow.py
Then I have added this into crontab.
@reboot /home/pi/Desktop/workfolder/startup.sh > /home/pi/Documents/error.log 2>&1
When I reboot, error log gives me the following error.
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.
I had some other issues which I was able to solve but I am stuck at this one. When I run my script via terminal, my screen does start. As far as I know, Xorg is installed since lxde is running. I have also changed sleep 10 to sleep 30 to make sure if script was not running too early. But still gives the same error.