Raspberry Pi Camera: PermissionError when saving on a mounted USB stick

274 views Asked by At

I have a simple project with my Raspberry Pi 4: When I take pictures with a Pi Camera, the pictures are saved in the home directory. But I want them to be saved on a USB stick.

I created a target folder at /mount/mydisk to be the mount point of the storage device but I get the PermissionError every time I shoot a picture.

This is the code:

def picture():
    timestamp=datetime.now()
    file_name='/media/pi/INTENSO'+str(timestamp)+'.jpg'
    pc.capture(file_name)

I also tried it with a link to /mnt/mydisk, /dev/sda1 but none of them work.

1

There are 1 answers

0
hhz On

This is about permissions of the user of your operating system (I assume raspian in this case). You either need to give the user executing you code the permission to write files into desired location or use the root user to execute the script. This one is a good source to read into this topic: https://open.oregonstate.education/computationalbiology/chapter/permissions-and-executables/