Hi I am trying to autostart a python script . I have edited the rc.local file to add the file location before exit 0..

sudo python /home/pi/myscript.py &

The myscript.py has executable permission . But the python script doesnt run .

I have also tried to add the file to .bashrc but when raspi is rebooted the sccript does not start . But when i connect to raspi using putty terminal from ubuntu machine ..i get a

tkinter.Tclerror: no display name and no $DISPLAY environmental variable  error 

..which is usually what get when i run the script from putty ..

  • As the problem and answer are essentially the same I have closed this question as a duplicate. – Steve Robillard Aug 4 '15 at 11:13
  • Don't use sudo in rc.local, init runs it with privileges anyway. Note you can't start a graphical app that way; if you want to replace the GUI login at boot that's a complex task. If you want to start it in a desktop session at normal login, see here. WRT ssh, try export $DISPLAY=:0 but that will start the app on the display connected to the pi, not your ssh terminal. – goldilocks Aug 4 '15 at 13:55
  • Here's a Q&A about that: raspberrypi.stackexchange.com/q/6753/5538 If you want to go for the "complex task" mentioned above, you'll need to ask a more specific question and detail exactly what it is you are trying to achieve -- what the app does, where and when you want it displayed, and how this should relate to the normal login screen. – goldilocks Aug 4 '15 at 14:03
  • I removed the python script i wanted to autostart from rc.local ...and added it to .bashrc ...it still doesnt start the script but when i open the terminal ..the script starts on its own ..Its a python scirpt that has a gui based on Tkinter . – Deepworks Aug 5 '15 at 4:11

Browse other questions tagged or ask your own question.