question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"pip.exe install --upgrade pip" fails on Windows (trying to move/delete running pip.exe)

See original GitHub issue
  • Pip version: 7.1.0
  • Python version: Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
  • Operating System: Windows-10-10.0.10586-SP0 (<= platform.platform())

Description:

Pip upgrade using pip.exe install --upgrade pip fails and leave python pip broken (pip.exe remains, but pip-script.py was deleted).

AFAIK upgrade fail because it is trying to delete pip.exe which is currently running. IMHO for a pip upgrade this step should be skipped as it will point to the same pip-script.py after re-install.

Fixing broken pip:

The broken pip caused by the failed upgrade can be fixed by running:

easy_install pip

What I’ve run:

Notes that below I run the command Scripts\pip.exe install --upgrade pip to make the issue more obvious. Typing pip install --upgrade pip executes the same command.

shutil.move is trying to copy/delete the executable as it is on a different drive than the TEMP directory.

    e:\venv_pip_upgrade>Scripts\activate.bat
    (venv_pip_upgrade) e:\venv_pip_upgrade>Scripts\pip.exe install --upgrade pip
    You are using pip version 7.1.0, however version 8.1.2 is available.
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.
    Collecting pip
      Using cached pip-8.1.2-py2.py3-none-any.whl
    Installing collected packages: pip
      Found existing installation: pip 7.1.0
        Uninstalling pip-7.1.0:
    Exception:
    Traceback (most recent call last):
      File "C:\Python35\lib\shutil.py", line 538, in move
        os.rename(src, real_dst)
    OSError: [WinError 17] The system cannot move the file to a different disk drive: 'e:\\venv_pip_upgrade\\scripts\\pip.exe' -> 'C:\\Users\\Zark\\AppData\\Local\\Temp\\pip-ydctswjh-uninstall\\venv_pip_upgrade\\scripts\\pip.exe'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "e:\venv_pip_upgrade\lib\site-packages\pip-7.1.0-py3.5.egg\pip\basecommand.py", line 223, in main
      File "e:\venv_pip_upgrade\lib\site-packages\pip-7.1.0-py3.5.egg\pip\commands\install.py", line 299, in run
      File "e:\venv_pip_upgrade\lib\site-packages\pip-7.1.0-py3.5.egg\pip\req\req_set.py", line 640, in install
      File "e:\venv_pip_upgrade\lib\site-packages\pip-7.1.0-py3.5.egg\pip\req\req_install.py", line 726, in uninstall
      File "e:\venv_pip_upgrade\lib\site-packages\pip-7.1.0-py3.5.egg\pip\req\req_uninstall.py", line 125, in remove
      File "e:\venv_pip_upgrade\lib\site-packages\pip-7.1.0-py3.5.egg\pip\utils\__init__.py", line 314, in renames
      File "C:\Python35\lib\shutil.py", line 553, in move
        os.unlink(src)
    PermissionError: [WinError 5] Access is denied: 'e:\\venv_pip_upgrade\\scripts\\pip.exe'

    (venv_pip_upgrade) e:\venv_pip_upgrade>Scripts\pip.exe install --upgrade pip
    Cannot open e:\venv_pip_upgrade\Scripts\pip-script.py

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

23reactions
jamaddencommented, Jun 19, 2016

The usual workaround to this is python -m pip install --upgrade pip.

11reactions
RajeshRajchalcommented, Jul 3, 2016

And when running the command -m pip install --upgrade pip, make sure you are running command as administrator.

find the "Command Prompt Right click on “Command Prompt” Run as Administrator

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Access is denied" while upgrading pip.exe on Windows
I ran command prompt as administrator (from your comments), and then typed in pip install --upgrade pip . It returned error messages out...
Read more >
How to Upgrade pip on Windows 10 (2022) - YouTube
In this video, learn to Upgrade and Update pip on Windows 10. Pip is used to install and manage Python libraries.
Read more >
Pip upgrade to 22.3 windows10 - Discussions on Python.org
Hi all, I'm trying to upgrade my pip version. I'm running in cmd promtp as admin and my error is this When I...
Read more >
Pip Command Not Found on Windows: A Guide | Built In
A “pip: command not found” error occurs when you haven't properly installed the package installer for Python (pip) on your computer.
Read more >
Installation - pip documentation v22.3.1
Python comes with an ensurepip module1, which can install pip in a Python environment. Linux. $ python -m ensurepip --upgrade.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found