在更新pip时出现错误,日志如下:
PS E:\VS Code\python> pip install --upgrade pip
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPCollecting pip
Using cached pip-20.2.3-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.1.1
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'd:\\program files\\python38\\scripts\\pip.exe'
Consider using the `--user` option or check the permissions.
PS E:\VS Code\python> pip
Traceback (most recent call last):
File "d:\program files\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "d:\program files\python38\lib\runpy.py", line 87, in _run_code
File "D:\Program Files\Python38\Scripts\pip.exe\__main__.py", line 4, in <module>
PS E:\VS Code\python> pip
Traceback (most recent call last):
File "d:\program files\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "d:\program files\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
ModuleNotFoundError: No module named 'pip'
出现这个问题后导致pip找不到了
可以这样解决
1、执行python -m ensurepip
PS E:\VS Code\python> python -m ensurepip
Looking in links: c:\Users\16838\AppData\Local\Temp\tmplkytwhki
Requirement already satisfied: setuptools in d:\program files\python38\lib\site-packages (47.1.0)
Processing c:\users\16838\appdata\local\temp\tmplkytwhki\pip-20.1.1-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-20.1.1
2、执行python -m pip install --upgrade pip
PS E:\VS Code\python> python -m pip install --upgrade pip
Collecting pip
Using cached pip-20.2.3-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.1.1
Uninstalling pip-20.1.1:
Successfully uninstalled pip-20.1.1
Successfully installed pip-20.2.3