0

I try to hit the run button after opening the "thonny python ide" successfully with the following adjustments in /etc/xdg/lxsession/LXDE-pi/autostart

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@thonny /usr/bin/home/pi/Dekstop/cao.py
@xscreensaver -no-splash
point-rpi

Has anyone an idea how I can do that manually in autostart?
I am asking for this different way to start a python script because I have tried everything else with rc.local etc.

6
  • Bad idea running a program permanently in Thonny. It adds an extra layer of complexity that can cause problems. Why can’t you run the Python program on its own? – CoderMike Jan 10 '20 at 17:34
  • Have you also got a typo - Dekstop / Desktop ? – CoderMike Jan 10 '20 at 18:04
  • @CoderMike because I developed it in thonny and do not know how to make it run elsewhere – paranoia_do Jan 10 '20 at 19:21
  • @CoderMike what is a typo Desktop / Desktop? – paranoia_do Jan 10 '20 at 19:21
  • Thonny just runs the python executable behind the scenes. From a command line, try this: python3 /usr/bin/home/pi/Dekstop/cao.py and see if that starts your program the way you want. – John S Jan 10 '20 at 20:12
1

Firstly I am assuming that your program cao.py is actually locate in /home/pi/Desktop

Your question appears to have the path wrong and the Desktop folder spelt wrong.

I've create the following simple program as an example:

import time
print('cao')
time.sleep(10)

To run this program on its own open a 'Terminal' window and use:

python3 /home/pi/Desktop/cao.py

enter image description here

If you want this to start automatically from /etc/xdg/lxsession/LXDE-pi/autostart add the following to the autostart file:

@lxterminal -e python3 /home/pi/Desktop/cao.py

If you want this to start automatically from /etc/rc.local add the following to the rc.local file before 'exit 0':

python3 /home/pi/Desktop/cao.py >> /home/pi/log.txt 2>&1 &

This will output any print or error messages to log.txt

2
  • 1
    Thanks for the help. You are right, I have added too much on the Desktop path. Can you tell me what the difference is between rc.local and @lxterminal? I have tried it with @lxterminal -e python3 /home/pi/Desktop/cao.py and it did work. Thank you very much! – paranoia_do Jan 10 '20 at 20:50
  • 1
    Starting a program in rc.local will run the program as root user, not pi. You also won't see the output unless piping to a file like this example. Using @lxterminal in autostart will open a Terminal window then run the program, so you can see the output. – CoderMike Jan 10 '20 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.