Python 3.7 升级 pip 时报错:Unable to find resource t64.exe in package pip._vendor.distlib

今天将 Win10 系统上的 pip 由20.02 升级到 21.0.1 时发生了报错。

python -m pip install –upgrade pip

当前使用的 Python 版本为 3.7.6,报错信息为:

ERROR: Exception:
Traceback (most recent call last):
File “C:\Users\LYJ\AppData\Roaming\Python\Python37\site-packages\pip\_internal\cli\base_command.py”, line 186, in _main
status = self.run(options, args)
File “C:\Users\LYJ\AppData\Roaming\Python\Python37\site-packages\pip\_internal\commands\install.py”, line 404, in run
use_user_site=options.use_user_site,
File “C:\Users\LYJ\AppData\Roaming\Python\Python37\site-packages\pip\_internal\req\__init__.py”, line 71, in install_given_reqs
**kwargs
File “C:\Users\LYJ\AppData\Roaming\Python\Python37\site-packages\pip\_internal\req\req_install.py”, line 815, in install
warn_script_location=warn_script_location,
File “C:\Users\py\AppData\Roaming\Python\Python37\site-packages\pip\_internal\operations\install\wheel.py”, line 614, in install_wheel
warn_script_location=warn_script_location,
File “C:\Users\py\AppData\Roaming\Python\Python37\site-packages\pip\_internal\operations\install\wheel.py”, line 548, in install_unpacked_wheel
generated_console_scripts = maker.make_multiple(scripts_to_generate)
File “C:\Users\py\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py”, line 415, in make_multiple
filenames.extend(self.make(specification, options))
File “C:\Users\py\AppData\Roaming\Python\Python37\site-packages\pip\_internal\operations\install\wheel.py”, line 280, in make
return super(PipScriptMaker, self).make(specification, options)
File “C:\Users\py\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py”, line 404, in make
self._make_script(entry, filenames, options=options)
File “C:\Users\py\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py”, line 304, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File “C:\Users\py\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py”, line 239, in _write_script
launcher = self._get_launcher(‘t’)
File “C:\Users\py\AppData\Roaming\Python\Python37\site-packages\pip\_vendor\distlib\scripts.py”, line 383, in _get_launcher
raise ValueError(msg)
ValueError: Unable to find resource t64.exe in package pip._vendor.distlib

搜了一下,解决办法很简单:先手动卸载 pip 再安装就行了。

python -m pip uninstall pip

python -m pip install –upgrade pip

记录一下,供大家参考。