How to reinstall after windows pip upgrade fails

After the pip upgrade fails, the error is reported as follows:

C:\Users\xxx>pip --version
Traceback (most recent call last):
  File "d:\programfiles\python3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "d:\programfiles\python3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\programFiles\python3\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'

Solution:
Step 1:

python -m ensurepip

Step two:

python -m pip install --upgrade pip

Why does pip upgrade fail under Windows? There are several reasons:

  • Port 80 or 443 is blocked

  • Problems due to incorrect operating system permissions

  • SSL (Secure Sockets Layer) has expired

  • Old installation package containing garbled characters

  • Wrong Python version

  • web proxy is not set up correctly

  • The key to connect to the source repository has expired

Guess you like

Origin blog.csdn.net/lenovo96166/article/details/129192392