So you are a Python developer and you have been trying to access your directory but with no luck as you keep getting the error message that says “permission error winerror 5 access is denied”. This error shows up for every Python developer every once in a while and it usually occurs when you are working with an application made with Python and you are trying to run a script or attempting to delete a directory.
However, fortunately, there is not much to worry about. There are a bunch of solutions that might work for you and you can go back to doing your regular programming once it’s fixed!
Method #1: Run As Administrator
Firstly, try running the script as the administrator. If you are being denied access to a Python script, it could be due to a number of reasons. One of them could be you not having access to the script because you are not the administrator.
- First, right-click on the script’s icon.
- In the dropdown menu, choose Properties.
- Under the General tab, you should be able to select Advanced.
- Navigate the ‘Run As Administrator’ option, check the box next to it.
- Click Apply and then OK.
After this you should be able to run the script without any disruptions or problems with permission.
Method #2: Reinstall Python
You could be using an older version of Python which might cause it to bug and show you the “permission error winerror 5 access is denied” error message. The latest versions fix old bugs and improve a lot of things, so you should keep it updated at all times.
The quickest way to do this is:
- Uninstall the older version of Python by going into your Control Panel
- > Programs
- > and Click on Uninstall
- > Find the relevant program and uninstall it.
- After uninstalling it, you can go to Python’s official website and download the latest version.
- You can now launch the newer version with the help of the py.exe launcher.
- Restart your computer and try to access your program again and it should work.
Method #3: Set Up Working Directory Path
Sometimes “permission error Winerror 5 access is denied” can occur when there are some faults with the working directory path. If you are using PyCharm, the Python IDE, for the first time, it is likely that the working directory path is not set yet.
While PyCharm creates all directories in the python interpreter location itself, you will need to set the working directory path to the base project directory.
To solve this,
- Go to Run Configurations menu of PyCharm and change the file path to that of your project directory.
Why Is This Error Occuring?
If you are getting the error message for the first time, you might be confused as to what is causing this error in the first place. There are multiple reasons to it, and while it might be frustrating to be interrupted in your programming, it is nothing to worry about.
- Sometimes when developers try to install new packages or update the existing POP application, this blocks the project. This is because the third party packages and APIs are crucial to programming in Python.
- It might also be because of another program you might have installed. Such as the third party app called TensorFlow.TensorFlow does not work well with some Python packages and some developers have complained about being denied access when installing the TensorFlow package.
Third party applications can be a great addition to your programming. However, some of them might not work too well with Python. Maybe you do not need to fix anything but just get rid of the third party apps first and check if it works.
Conclusion: Programming requires a bunch of applications to work together and sometimes one of them can glitch or cause the other to bug out. Sometimes it’s temporary and requires a quick fix, if however- it does not get fixed with these solutions, you can simply contact their customer support or check a community help page to guide you better.