Description
Description
While using pip it recommended running python -m pip install --upgrade pip
, however when I did as such it uninstalled the old version of pip, but failed to modify the /Scripts/pip.exe
file. This resulted in a broken pip installation where the pip command existed, but the module itself was gone.
Expected behavior
Pip should've upgraded, rolled back, or prechecked for potential permission errors to prevent destroying itself.
pip version
22.2.2
Python version
Python 3.10.8 (tags/v3.10.8:aaaf517) [MSC v.1933 64 bit (AMD64)] on win32
OS
win10 - 21H2 - 19044.2130
How to Reproduce
- python
/Lib
- 'Authenticated Users' has write permission, along with system and admins - python
/Scrips
- only system and admins have write permission - probably doesn't have to be this exact permission setup, as long as
/Lib
can be modified and/Scripts
can't at a user level.
run python -m pip install --upgrade pip
or python -m pip install --force-reinstall pip
Output
$ python -m pip install --force-reinstall pip
WARNING: Ignoring invalid distribution -p (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -p (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
Collecting pip
Using cached pip-22.3-py3-none-any.whl (2.1 MB)
WARNING: Ignoring invalid distribution -p (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
Installing collected packages: pip
Attempting uninstall: pip
WARNING: Ignoring invalid distribution -p (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
Found existing installation: pip 22.2.2
Uninstalling pip-22.2.2:
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'c:\\python310\\scripts\\pip.exe'
Consider using the `--user` option or check the permissions.
WARNING: Ignoring invalid distribution -p (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -p (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -p (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\python310\lib\site-packages)
$ pip
Traceback (most recent call last):
File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Python310\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'
I've broken Pip so many times testing this just to report this issue. I use the python installer to 'modify' pip back into existence every time. Probably why I have so many invalid distribution
warnings. Doesn't help that I have to run it twice, the first time going 'modify' -> uncheck Pip, then I run 'modify' -> leave pip checked.
Code of Conduct
- I agree to follow the PSF Code of Conduct.