I'm trying to create a folder inside a folder, first I check if that directory exists and create it if necessary:
name = "User1"
if not os.path.exists("/pdf_files/%s" % name):
os.makedirs('/pdf_files/%s' % name )
Problem is that i'm getting an error : OSError: [Errno 13] Permission denied: '/pdf_files'
This folder named: pdf_file
that I created have all permissions: drwxrwxrwx
or '777'
I searched about this and I saw some solutions but none of them solved my problem. Can somebody help me ?
To fix PermissionError: [Errno 13] Permission denied with Python open, we should make sure the path we call open with is a file. to make sure that the path is a path to a file with os. path. isfile before we call open to open the file at the path .
We can solve this error by Providing the right permissions to the file using chown or chmod commands and also ensuring Python is running in the elevated mode permission .
The PermissionError: [errno 13] permission denied error occurs when you try to access a file from Python without having the necessary permissions. To fix this error, use the chmod or chown command to change the permissions of the file so that the right user and/or group can access the file.
You are trying to create your folder inside root directory (/
).
Change /pdf_files/%s
to pdf_files/%s
or /home/username/pdf_files/%s
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With