I have the following script
#!/bin/bash echo "Welcome to auto shell" cd /home/pi/Desktop/Home echo "Running the server now.....!" echo "*************************" |& tee -a /home/pi/Desktop/Home/logs.log echo "Today is " |& tee -a /home/pi/Desktop/Home/logs.log date |& tee -a /home/pi/Desktop/Home/logs.log python3 Server.py |& tee -a /home/pi/Desktop/Home/logs.log
But the output is :
Today is Sat Nov 11 01:03:46 EST 2017 Traceback (most recent call last): File "Server.py", line 1, in <module> import radiojavan as rj File "/home/pi/Desktop/Home/radiojavan.py", line 2, in <module> import pyautogui as gui File "/home/pi/.local/lib/python3.5/site-packages/pyautogui/__init__.py", line 115, in <module> from . import _pyautogui_x11 as platformModule File "/home/pi/.local/lib/python3.5/site-packages/pyautogui/_pyautogui_x11.py", line 160, in <module> _display = Display(os.environ['DISPLAY']) File "/usr/lib/python3.5/os.py", line 725, in __getitem__ raise KeyError(key) from None KeyError: 'DISPLAY'
the app has no problem running when I manually run it by typing python3 Server.py
UPDATE: Clarification to the post I need the app to start running after the user pi logged in because it will need to get access to chrome
Advertisement
Answer
So after the previous comment was made by rzzzwilson I did look into script after login and this fixed my issue
cd /home/pi/.config/lxsession/LXDE-pi/
nano autostart
add this to the end of the file
@/usr/bin/python3 /home/pi/Desktop/Home/Server.py