I have created a simple python script for the pi camera which works when run as is.

the file is located in ~/Destop/python


import picamera
import time
camera = picamera.Picamera()

I would like this to launch at startup/login, so I have done the following:

sudo nano /etc/rc.local

where I added the following line of code before exit 0

python /home/me/Desktop/python/cameratest.py &

i then run reboot

No picture is taken and among the boot strings an error rc.local.... 'directory does not exist' pops up. Can anyone advise me how to proceed?

1 Answer 1


Try including the full path to the python executable in rc.local, for example

/usr/bin/python /home/me/Desktop/python/cameratest.py &
  • Hi, I just tried that out. While it removed the error from the boot sequence, it still did not take a photo
    – CLopes1987
    Commented Sep 25, 2019 at 21:50
  • Yes it did. It just stored the photo in the current working directory when rc.local gets started as a root process by systemd. It could be in /etc.
    – Dougie
    Commented Sep 25, 2019 at 22:41
  • @Dougie you are right, it did take the photo. But for some reason it was in the root directory ( /example.jpg) . My understanding was that the jpg would be saved in the directory python called it from, hence using the full path name?
    – CLopes1987
    Commented Sep 26, 2019 at 15:13
  • Without the full path the system did not know where to find the python executable (hence the error message) and could not execute the script (hence no saved picture). With the full path, the script was executed and (as Dougie said) the picture was saved in the current working directory of user executing the command (root). Change the python script if you want the picture to be saved in another directory.
    – yesno
    Commented Sep 26, 2019 at 15:35
  • @yesno thank you, I marked your answer as approved since it solved the issue. I added import os and then os.chdir("/home/me/Desktop") to test out choosing the save location which worked. Do you recommend this being the best way to go about this or have any advice if i should go about this differently?
    – CLopes1987
    Commented Sep 26, 2019 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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