pip升级报错解决办法

1、报错信息

Microsoft Windows [版本 10.0.19044.2364]
(c) Microsoft Corporation。保留所有权利。

C:\Users\LIN>python.exe -m pip install --upgrade pip
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: pip in c:\users\lin\appdata\roaming\python\python39\site-packages (22.2.2)
Collecting pip
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/09/bd/2410905c76ee14c62baf69e3f4aa780226c1bbfc9485731ad018e35b0cb5/pip-22.3.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 22.2.2
    Uninstalling pip-22.2.2:
      Successfully uninstalled pip-22.2.2
  Rolling back uninstall of pip
  Moving to c:\users\lin\appdata\roaming\python\python39\scripts\pip.exe
   from C:\Users\LIN\AppData\Local\Temp\pip-uninstall-7ambfccl\pip.exe
  Moving to c:\users\lin\appdata\roaming\python\python39\scripts\pip3.9.exe
   from C:\Users\LIN\AppData\Local\Temp\pip-uninstall-7ambfccl\pip3.9.exe
  Moving to c:\users\lin\appdata\roaming\python\python39\scripts\pip3.exe
   from C:\Users\LIN\AppData\Local\Temp\pip-uninstall-7ambfccl\pip3.exe
  Moving to c:\users\lin\appdata\roaming\python\python39\site-packages\pip-22.2.2.dist-info\
   from C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\~ip-22.2.2.dist-info
  Moving to c:\users\lin\appdata\roaming\python\python39\site-packages\pip\
   from C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\~ip
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\req_command.py", line 247, in wrapper
    return func(self, options, args)
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_internal\commands\install.py", line 461, in run
    installed = install_given_reqs(
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_internal\req\__init__.py", line 73, in install_given_reqs
    requirement.install(
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_internal\req\req_install.py", line 790, in install
    install_wheel(
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_internal\operations\install\wheel.py", line 727, in install_wheel
    _install_wheel(
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_internal\operations\install\wheel.py", line 644, in _install_wheel
    generated_console_scripts = maker.make_multiple(scripts_to_generate)
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\distlib\scripts.py", line 436, in make_multiple
    filenames.extend(self.make(specification, options))
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_internal\operations\install\wheel.py", line 425, in make
    return super().make(specification, options)
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\distlib\scripts.py", line 425, in make
    self._make_script(entry, filenames, options=options)
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\distlib\scripts.py", line 325, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\distlib\scripts.py", line 249, in _write_script
    launcher = self._get_launcher('t')
  File "C:\Users\LIN\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\distlib\scripts.py", line 404, in _get_launcher
    raise ValueError(msg)
ValueError: Unable to find resource t64.exe in package pip._vendor.distlib

[notice] A new release of pip available: 22.2.2 -> 22.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip

2、解决方法

卸载setuptools

python -m pip uninstall pip setuptools
C:\Users\LIN>python -m pip uninstall pip setuptools
Found existing installation: pip 22.2.2
Uninstalling pip-22.2.2:
  Would remove:
    c:\users\lin\appdata\roaming\python\python39\scripts\pip.exe
    c:\users\lin\appdata\roaming\python\python39\scripts\pip3.9.exe
    c:\users\lin\appdata\roaming\python\python39\scripts\pip3.exe
    c:\users\lin\appdata\roaming\python\python39\site-packages\pip-22.2.2.dist-info\*
    c:\users\lin\appdata\roaming\python\python39\site-packages\pip\*
Proceed (Y/n)?
  Successfully uninstalled pip-22.2.2
Found existing installation: setuptools 58.1.0
Uninstalling setuptools-58.1.0:
  Would remove:
    c:\program files\python39\lib\site-packages\_distutils_hack\*
    c:\program files\python39\lib\site-packages\distutils-precedence.pth
    c:\program files\python39\lib\site-packages\pkg_resources\*
    c:\program files\python39\lib\site-packages\setuptools-58.1.0.dist-info\*
    c:\program files\python39\lib\site-packages\setuptools\*
Proceed (Y/n)? y
  Successfully uninstalled setuptools-58.1.0

3、重新输入升级命令

python.exe -m pip install --upgrade pip
C:\Users\LIN>python.exe -m pip install --upgrade pip
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: pip in c:\program files\python39\lib\site-packages (22.3.1)

提示已升级

4、重新安装setuptools

C:\Users\LIN>pip install --upgrade setuptools
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting setuptools
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ef/e3/29d6e1a07e8d90ace4a522d9689d03e833b67b50d1588e693eec15f26251/setuptools-65.6.3-py3-none-any.whl (1.2 MB)
Installing collected packages: setuptools
Successfully installed setuptools-65.6.3

本当の声を響かせてよ