pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.53k stars 3.03k forks source link

Upgrading pip will brake the installation if run-time is located in a different Windows mapped drive. #5701

Closed VictorGaiva closed 4 years ago

VictorGaiva commented 6 years ago

Environment

Command was ran inside VSCode Terminal (PS). Description

While attempting to upgrade pip from version 9.0.1 to version 18.0 using the command 'pip install --upgrade pip' isn't able to complete, giving an error message, saying that it was unable to move files from one drive to the other due to denied access. . Attempting to run the upgrade command again failed, giving an error saying ModuleNotFoundError: No module named 'pip' Expected behavior

The command should've been able to upgrade the installation and it was supposed to run correctly after that.

How to Reproduce

Running the pip 9.0.1 upgrade from any cmd window on a Windows 10 computer, while having a python 3.6.4 installed on a different drive mapped by Windows,

Output PS M:\Common\Web-Scrapper> pip install requests Requirement already satisfied: requests in m:\windows\tools\lib\site-packages Requirement already satisfied: idna<2.8,>=2.5 in m:\windows\tools\lib\site-packages (from requests) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in m:\windows\tools\lib\site-packages (from requests) Requirement already satisfied: certifi>=2017.4.17 in m:\windows\tools\lib\site-packages (from requests) Requirement already satisfied: urllib3<1.24,>=1.21.1 in m:\windows\tools\lib\site-packages (from requests) You are using pip version 9.0.1, however version 18.0 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. PS M:\Common\Web-Scrapper> pip install --upgrade pip Collecting pip Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 666kB/s Installing collected packages: pip Found existing installation: pip 9.0.1 Uninstalling pip-9.0.1: Exception: Traceback (most recent call last): File "m:\windows\tools\lib\shutil.py", line 544, in move os.rename(src, real_dst) OSError: [WinError 17] O sistema não pode mover o arquivo para uma unidade de disco diferente: 'm:\windows\tools\scripts\pip.exe' -> 'C:\Users\Victor\AppData\Local\Temp\pip-32kf3hlo-uninstall\windows\tools\scripts\pip.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "m:\windows\tools\lib\site-packages\pip\basecommand.py", line 215, in main File "m:\windows\tools\lib\site-packages\pip\commands\install.py", line 342, in run File "m:\windows\tools\lib\site-packages\pip\req\req_set.py", line 778, in install File "m:\windows\tools\lib\site-packages\pip\req\req_install.py", line 754, in uninstall File "m:\windows\tools\lib\site-packages\pip\req\req_uninstall.py", line 115, in remove File "m:\windows\tools\lib\site-packages\pip\utils__init.py", line 267, in renames File "m:\windows\tools\lib\shutil.py", line 559, in move os.unlink(src) PermissionError: [WinError 5] Acesso negado: 'm:\windows\tools\scripts\pip.exe' PS M:\Common\Web-Scrapper> pip install --upgrade pip Traceback (most recent call last): File "m:\windows\tools\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "m:\windows\tools\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "M:\Windows\Tools\Scripts\pip.exe\main.py", line 5, in ModuleNotFoundError: No module named 'pip' PS M:\Common\Web-Scrapper> pip install --upgrade pip Traceback (most recent call last): File "m:\windows\tools\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "m:\windows\tools\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "M:\Windows\Tools\Scripts\pip.exe\main.py", line 5, in ModuleNotFoundError: No module named 'pip' PS M:\Common\Web-Scrapper> pip Traceback (most recent call last): File "m:\windows\tools\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "m:\windows\tools\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "M:\Windows\Tools\Scripts\pip.exe\main__.py", line 5, in ModuleNotFoundError: No module named 'pip' PS M:\Common\Web-Scrapper> clear

Paste the output of the steps above, including the commands themselves and
pip's output/traceback etc.
VictorGaiva commented 6 years ago

Would like to add that running the 'get-pip.py' with the upgraded version of pip is enough to fix this issue. But I would like to have an idea how to avoid this issue from happening again, since the installation is still on a different Drive and it might happen again on future upgrades.

chrahunt commented 4 years ago

Hi @VictorGaiva. Thanks for reporting this!

This root problem is that pip was not protecting itself from upgrade when invoked as pip on Windows. This was fixed in #6864, so I will close this issue. Please do let us know if you're still having any problems.