PermissionError: [Errno 13] Permission Denied: [Python Fix]
Try these solutions to fix PermissionError [Errno 13] Permission denied
4 min. read
Updated on
Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more
Python is designed to build websites, software, and more using a high-level programming language. However, users have recently reported receiving a permission denied error in Windows 11. Hereโs how to fix PermissionError [Errno 13] Permission denied error in Python.
Because Python uses a general-purpose language, it can be used to build various programs rather than focusing on a specific variable.
For those wanting to learn more about developing and coding, Python is one of the easiest programming languages to learn, making it perfect for beginners.
Why do I get the permission denied error in Python?
Users encounter PermissionError: [Errno 13] Permission denied error if providing Python with a file path that does not have permission to open or edit the file. By default, some files do not allow certain permissions. This error may also occur if providing a folder rather than a file.
If the file is already being operated by another process, then you may encounter the permission denied error in Python. If youโre receiving the Python runtime error, we offer solutions for that as well.
How do I fix the Python permission denied error in Windows 11?
1. Check file path
One of the leading causes of PermissionError: [Errno 13] Permission denied is because Python is trying to open a folder as a file. Double-check the location of where you want to open the file and ensure there isnโt a folder that exists with the same name.
Run the os.path.isfile(filename) command replacing filename with your file to check if it exists. If the response is false, then the file does not exist, or Python cannot locate it.
2. Allow permissions using chomd
If the file does not have read and write permissions enabled for everyone, then you may encounter the permission denied error in Python. Try entering the chomd 755 filename command and replace filename with the name of your file.
This command gives everyone permission to read, write, and execute the file, including the owner. Users can also apply this command to entire directories. Running the ls -al command will provide a list of files and directories and their permissions.
3. Adjust file permissions
- Navigate to the location of your file in file explorer.
- Right-click on the file and select Properties.
- Click the Security tab then select your name under Group or user names.
- Select Edit and go through and check permissions.
- Click Apply then OK.
Adjusting the permissions of the file that youโre trying to open will allow Python to read, write, and execute the file.
4. Turn off execution aliases
- Click on Start and open Settings (or press Windows + I).
- Open Apps then select Apps & features.
- Open the drop-down menu next to More settings.
- Click App execution aliases.
- Locate the two App Installers for python.exe and python3.exe and toggle both to Off.
Python was added to the Microsoft Store for version 3.7 which introduced permission denied errors because it created two installers: python.exe and python3.exe. Disabling the Microsoft Store versions of Python should fix the permissions denied error.
5. Update Windows and drivers
- Click on Start and open Settings (or press Windows + I).
- Scroll down and select Windows Update.
- Perform any available updates.
- Select Advanced options.
- Under Additional options, click on Optional updates.
- Run any driver updates.
If youโre suddenly encountering the Python permission denied error and none of the above solutions worked, then check for any Windows 11 updates and perform any available driver updates.
What is the latest version of Python?
As of the release of this article, the latest version of Python is 3.10.7, which is available for Windows 10 and newer and is not compatible with older versions, including Windows 7. Python supports Windows, macOS, Linux/UNIX, and more.
However, If users want to use older versions of Python, they can access releases 2.7 and newer, or they can download a specific version of a release.
If you want a quick way to open PY files on Windows 10 and 11, we offer a guide for that as well. To learn how to deal with errors, be sure to visit our Try-except-print in Python guide.
We also have a great guide on what to do if _xsrf argument missing from post, so don’t miss it. We also have a new guide on Cannot open shared object no such file or directory error, so don’t miss it.
Hopefully, one of the above solutions helped you fix the Python permission denied error in Windows 11. Let us know in the comments which step worked for you or if you have any suggestions for a different solution.
User forum
0 messages