Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

makedirs gives OSError: [Errno 13] Permission denied: '/pdf_files'

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 ?

like image 558
Babel Avatar asked Sep 01 '15 11:09

Babel


People also ask

How do I fix errno 13 Permission denied Python?

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 .

How do I fix 13 permissions denied?

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 .

What does Errno 13 mean?

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.


1 Answers

You are trying to create your folder inside root directory (/).

Change /pdf_files/%s to pdf_files/%s or /home/username/pdf_files/%s

like image 174
Aleksandr Kovalev Avatar answered Oct 05 '22 23:10

Aleksandr Kovalev