Question

[Solved] Python – PIP install trouble shooting – PermissionError: [WinError 5] Access is denied

I get the following error when using PIP to either install new packages or even upgrade pip itself to the latest version. I am running pip on a windows 8.1 machine with Python 3.4.

The message is telling me I don’t have Administrative Permission on the files (my account is an Administrator Account).

I would appreciate any thoughts on how to resolve this, as it is getting in the way of installing packages and progressing with Python.

Error message:

Installing collected packages: pip
  Found existing installation: pip 6.0.8
    Uninstalling pip-6.0.8:
      Removing file or directory c:program files (x86)pythonpython34libsite-packagespip-6.0.8.dist-infodescription.rst
      Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:Program Files (x86)PythonPython34libshutil.py", line 523, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\program files (x86)\python\python34\lib\site-packages\pip-6.0.8.dist-info\description.rst' -> 'C:\Users\User\AppData\Local\Temp\pip-uze_sc4k-uninstall\program files (x86)\python\python34\lib\site-packages\pip-6.0.8.dist-info\description.rst'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:Program Files (x86)PythonPython34libsite-packagespipbasecommand.py", line 232, in main
    status = self.run(options, args)
  File "C:Program Files (x86)PythonPython34libsite-packagespipcommandsinstall.py", line 347, in run
    root=options.root_path,
  File "C:Program Files (x86)PythonPython34libsite-packagespipreqreq_set.py", line 543, in install
    requirement.uninstall(auto_confirm=True)
  File "C:Program Files (x86)PythonPython34libsite-packagespipreqreq_install.py", line 667, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "C:Program Files (x86)PythonPython34libsite-packagespipreqreq_uninstall.py", line 126, in remove
    renames(path, new_path)
  File "C:Program Files (x86)PythonPython34libsite-packagespiputils__init__.py", line 316, in renames
    shutil.move(old, new)
  File "C:Program Files (x86)PythonPython34libshutil.py", line 536, in move
    os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'c:\program files (x86)\python\python34\lib\site-packages\pip-6.0.8.dist-info\description.rst'

Solution #1:

E: Since this answer seems to have gained some popularity, I will add: doing things globally is most of the time not a great idea. Almost always the correct answer is: use a project environment where you’re not installing things globally, e.g. with virtualenv.


For those that may run into the same issue:

Run the command prompt as administrator. Having administrator permissions in the account is not always enough. In Windows, things can be run as administrator by right-clicking the executable and selecting “Run as Administrator”. So, type “cmd” to the Start menu, right click cmd.exe, and run it as administrator.

Respondent: Roope

Solution #2:

I know my answer would be weird but that’s what I have experienced just now.

I got the similar error when installing tensorflow package and I tried the same by opening powershell in windows as administrator but in vain.

Later I found out that I was already using numpy in one of the python scripts in an active python session. So I closed the Spyder IDE and tried to install the tensorflow package by running powershell as administrator and it worked.

Hope this will help somebody else like me who will open this older but useful post in upcoming days

Respondent: JKC

Solution #3:

Even you run from Administrator, it may not solve the issue if the pip is installed inside another userspace. This is because Administrator doesn’t own another’s userspace directory, thus he can’t see (go inside) the inside of the directory that is owned by somebody. Below is an exact solution.

python -m pip install -U pip --user //In Windows 

Note: You should provide –user option

pip install -U pip --user //Linux, and MacOS
Respondent: Uddhav Gautam

Solution #4:

For those who run into this issue and running the command prompt as administrator does not work this worked for me:

Since I had already tried a first time without running the cmd prompt as admin, in my c:Users”USER”AppDataLocalTemp folder I found it was trying to run files from the same pip-u2e7e0ad-uninstall folder. Deleting this folder from the Temp folder and retrying the installation fixed the issue for me.

Respondent: Michael Martin

Solution #5:

Do not use the command prompt in the IDE. Run the command prompt from windows as an administrator. I’m sure this will solve the problem. If not, uninstall pip and reinstall the latest one directly.

Respondent: Santa

Solution #6:

As of upgrading from pip 7.x.x to 8.x.x on Python 3.4 (for *.whl support).

Wrong command:
pip install --upgrade pip (can’t move pip.exe to temporary folder, permisson denied)

OK variant:
py -3.4 -m pip install --upgrade pip (do not execute pip.exe)

Respondent: Valerij

Solution #7:

I have had the same problem with anaconda on windows. It seems that there is an issu with mcAfee antivirus. If you deactivate it while running the updates or the installs, it allows you to properly run the installation.

Respondent: Netzsooc

Solution #8:

After seeing

You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

I ran

pip install -U pip

and hit this error

PermissionError: [WinError 5]

I tried again and got

pip install -U pip
ERROR: To modify pip, please run the following command:
c:python36-32python.exe -m pip install -U pip

After running that exact command, it worked.

For those promoting the use of virtual environments as a solution to this error, pip and virtualenv must be updated in your main install. Simply put, a virtual environment offers no solution to this problem.

Respondent: Wyrmwood

Solution #9:

TL;DR: python -m pip install -U pip, then try again.


I was already using a venv (virtualenv) in PyCharm.

Creating it I clicked inherit global site packages checkbox, to allow packages installed via an installer to work.
Now inside my venv there was no pip installed, so it would use the inherited global pip.

Here is how the error went:

(venv) D:pathtomyproject> pip install certifi  # or any other package

Would fail with

PermissionError: [WinError 5] Access denied: 'c:\program files\python36\Lib\site-packages\certifi'

Notice how that is the path of the system python, not the venv one.
However we want it to execute in the right environment.

Here some more digging:

(venv) D:pathtomyproject> which pip
/c/Program Files/Python36/Scripts/pip

(venv) D:pathtomyproject> which python
/d/path/to/my/project/venv/Scripts/python

So python is using the correct path, but pip is not?
Let’s install pip here in the correct one as well:

(venv) D:pathtomyproject> python -m pip install -U pip
... does stuff ...
Successfully installed pip

Now that’s better.
Running the original failing command again now works, as it is using the correct pip.

(venv) D:pathtomyproject> pip install certifi  # or any other package
... install noise ...
Successfully installed certifi-2019.9.11 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.7
Respondent: luckydonald

Solution #10:

I had this issue as well on Windows 10. Closing all my Jupyter Notebook sessions and re-running the pip install --upgrade commands as an administrator made the issue go away.

Respondent: davetunes

Solution #11:

python -m pip install -U pip --user //In Windows 

Note: You should provide –user option

pip install -U pip --user //Linux, and MacOS

Or, Run the cmd in Administrator mode.

Respondent: Azeez Bello

Solution #12:

Still relevant in 2018: don’t install packages as admin.

The by far more sensible solution is to use virtualenv to create a virtual environment directory (virtualenv dirname) and then activate that virtual environment with dirnameScriptActivate in Windows before running any pip commands. Or use pipenv to manage the installs for you.

That way, everything gets written to dirs that you have full write permission for, without needing UAC, and without global installs for local directories.

Solution #13:

Note that if you are installing this through Anaconda, you will need to open Anaconda as an administrator and then launch the command prompt from there.

Otherwise, you can also run “Anaconda prompt” directly as an administrator to uninstall and install packages.

Respondent: Nikhil Gupta

Solution #14:

Hi Could you try this line cmd its work for me

python -m pip install –user –upgrade pip

Respondent: Imad77

Solution #15:

Simply, Run the cmd in Administrator mode.

Respondent: Zeinab

Solution #16:

I ran into this issue when I was using pycharm to create and run a virtual environment – I clicked the “inherit global site packages” checkbox – deleting and recreating the venv solved the issue for me. If you used another means for creating your venv, make sure it IS NOT INHERITING global packages!
enter image description here

Respondent: Ben

Solution #17:

run command prompt as administrator and use ‘–user’ flag
eg. pip install –user –upgrade pandas

Respondent: user1721934

Solution #18:

I have the same error. Not sure why it happened. But I managed to upgrade by running:

pip install setuptools --upgrade --ignore-installed

After that, I used a PowerShell or Command Prompt – cmd in administrator mode to install the package:

pip install the-package

# or
easy_install the-package

Also, what they have already suggested: Installing packages using pip and virtual environments , which is the best practice for new projects.

Solution #19:

Just reinstall Python in another folder, e.g. c:python. After that you won’t be bothered by pip wanted administrator privileges.

Windows 10 Pro x64 user.

Respondent: Mark Twain

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy