0

I know this question has been asked before, but the methods referenced are not working for me. Currently I have done this: sudo nano /etc/xdg/lxsession/LXDE-pi/autostart and added the line @python3 /home/pi/Desktop/filename.py I tried with sudo but for some reason one of my python modules fails to import when I use sudo. Is there something wrong with my commands? Or is there an alternative way to run this python GUI script on startup?

  • Are you logging on as root? – Milliways Aug 15 at 11:54
  • @Milliways Yes, why? – Nadim Aug 15 at 11:57
  • Mixing root invocations with scripts in /home/pi is probably a bad idea with python as you are libel to end up with modules installed in /home/pi which won't be found when the script is invoked as root. – goldilocks Aug 15 at 14:32
  • Use a systemd unit file to run your script on startup. – Ingo Aug 15 at 20:31

Your Answer

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

Browse other questions tagged or ask your own question.