The Python Oracle

pip install access denied on Windows

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping

--

Chapters
00:00 Pip Install Access Denied On Windows
00:23 Accepted Answer Score 236
00:40 Answer 2 Score 85
01:17 Answer 3 Score 35
01:34 Answer 4 Score 22
02:22 Thank you

--

Full question
https://stackoverflow.com/questions/3117...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #windows #pip #accessdenied

#avk47



ACCEPTED ANSWER

Score 236


For Windows, in Command Prompt (Admin) try to run pip install using the Python executable:

python -m pip install mitmproxy

This should work, at least it worked for me for other package installation.




ANSWER 2

Score 85


Change your Python installation folder's security permissions by:

  1. Open a Python shell
  2. Go to task manager
  3. Find the python process
  4. Right-click and open location
  5. The folder will open in explorer, go up a directory
  6. Right-click the folder and select properties
  7. Click the security tab and hit 'edit'
  8. Add everyone and give them permission to Read and Write.
  9. Save your changes

If you open cmd as admin; then you can do the following:

If Python is set in your PATH, then:

python -m pip install mitmproxy



ANSWER 3

Score 35


Personally, I found that by opening cmd as admin then run python -m pip install mitproxy seems to fix my problem.

Note:- I installed python through chocolatey




ANSWER 4

Score 22


One additional thing that has not been covered in previous answers and that often cause issues on Windows and stopped me from installing some package despite running as admin is that you get the same permission denied error if there is another program that use some of the files you (or pip install) try to access. This is a really stupid "feature" of Windows that pops up many times, e.g. when trying to move some files.

In addition I have no clue how to figure out which program locks a particular file, so the easiest ting to do is to reboot and do the installation before starting anything, in particular before running e.g. Spyder or any other Python-based software. You can also try to close all programs, but it can be tricky to know which one actually holds a file. For a directory for example, it is enough that you have an Explorer window open at that directory.