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

2

16

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 ?

Fort answered 1/9, 2015 at 11:3 Comment(0)
P
34

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

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

Pampa answered 1/9, 2015 at 11:8 Comment(1)
Thanks a lot! I didn't noticed it earlier :)Fort
R
2

if you are trying to create your folder inside root directory (/), another simple way could be to add '.' before that. so say your /directory becomes ./directory

Revolute answered 25/11, 2018 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.