Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python | PermissionError: [Errno 13] Permission denied:

I am currently learning Python using Al Sweigart’s book. I have an issue with the open function when passing ‘w’ as an argument: it is supposed to create a file if the the filename I passed doesn’t exist but it doesn’t and instead it shows the error message in the image (this is an example from the book)

baconFile = open('bacon.txt', 'w')
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
baconFile = open('bacon.txt', 'w')
PermissionError: [Errno 13] Permission denied: 'bacon.txt'

Tha same error gets displayed when I use shelve.open from the shelve open.

Thank you for any explanation/solution.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried openeing other files with ‘w’ as an argument and it works only if the file exists already but if I try to open a non-existing one, it doesn’t create it like it’s supposed to and it just displays the same error.

>Solution :

The file bacon.txt is owned by a different user account.

You are running the program as a user that does not have permission to overwrite it.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading