When catching an error while executing [pip install] on Windows,
Running [python -m ensurepip] first might fix it.
Refer to the following
[Issues]-----------------------------------------------------------------------
①
D:\PycharmProjects>pip install pip --upgrade
Collecting pip
Downloading https://files.pythonhosted.org/packages/09/bd/2410905c76ee14c62baf69e3f4aa780226c1bbfc948573
1ad018e35b0cb5/pip-22.3.1-py3-none-any.whl (2.1MB)
|████████████████████████████████| 2.1MB 3.3MB/s
Installing collected packages: pip
Found existing installation: pip 19.2.3
Uninstalling pip-19.2.3:
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.
②
D:\PycharmProjects>pip install pip --upgrade --user
Traceback (most recent call last):
File "d:\program files\python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "d:\program files\python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "D:\Program Files\Python38\Scripts\pip.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
③
D:\PycharmProjects>python -m pip install --upgrade pip
D:\Program Files\Python38\python.exe: No module named pip
-----------------------------------------------------------------------
[Solutions]-----------------------------------------------------------------------
D:\PycharmProjects>python -m ensurepip
Looking in links: c:\Users\Ivan\AppData\Local\Temp\tmpmd0zj0t8
Requirement already satisfied: setuptools in d:\program files\python38\lib\site-packages (41.2.0)
Collecting pip
Installing collected packages: pip
Successfully installed pip-19.2.3
D:\PycharmProjects>python -m pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/09/bd/2410905c76ee14c62baf69e3f4aa780226c1bbfc94857
31ad018e35b0cb5/pip-22.3.1-py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 19.2.3
Uninstalling pip-19.2.3:
Successfully uninstalled pip-19.2.3
Successfully installed pip-22.3.1
-----------------------------------------------------------------------