user6556957
user6556957

Reputation: 205

Permission Denied Error Python

I am new to python and I am trying to open a file that contains a number of documents. I am using visual studio, this file is in the current directory (the same directory of the project files which are in) and I have added the file to the project in the IDE. The line of code is below:

file = open("name_of_file")

I am getting the following error: [Errno 13] Permission denied: 'name_of_file'

I hope this is a very simple fix? I tried to google it and look at some of the other posts, but had trouble following them. What are the reasons why this would happen?

Upvotes: 1

Views: 7242

Answers (1)

Right leg
Right leg

Reputation: 16720

Try to change the permissions with os.chmod function: os.chmod(path, mode), where mode is is numeric form (try with 777 to be sure). If this is not working, as Britt mentioned, it might be that the file is open in another application.

Upvotes: 1

Related Questions