//
you're reading...
Programming, Technical, Windows

Fix “[Error 5] Access is denied” when upgrading pip on windows

When using pip to install a python package from a Windows command window, pip displayed the following message

You are using pip version 7.0.1, however version 8.1.2 is available.
You should consider upgrading via the ‘pip install –upgrade pip’ command.

However, when I ran that command, pip displayed the following error

WindowsError: [Error 5] Access is denied: ‘c:\\users\\julie\\appdata\\local\\temp\\pip-w6u9yc-uninstall\\programs\\python27\\scripts\\pip.exe’

The solution (thanks to an answer on Stack Overflow) is to use the following command

python -m pip install –force-reinstall –upgrade pip

Explanation

From the Stack Overflow answer: “On Windows you can’t replace in-use executables”

  • The error is caused because pip.exe cannot replace itself whilst it is running
  • By running pip from python, the pip.exe executable is not running, so pip.exe can be replaced with the new version

 

Discussion

No comments yet.

Leave a comment