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

I try to create a folder inside a folder, first check if this directory exists, and create it if necessary:

name = "User1" if not os.path.exists("/pdf_files/%s" % name): os.makedirs('/pdf_files/%s' % name ) 

The problem is that I get the error message: OSError: [Errno 13] Permission denied: '/pdf_files'

This folder with the name: pdf_file that I created has all permissions: drwxrwxrwx or '777'

I searched about this and I saw some solutions, but none of them solved my problem. Can someone help me?

+5
source share
2 answers

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

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

+13
source

folder name "pdf_files" may not have enough permissions. you need to check the pdf_files folder.

-3
source

All Articles