解决升级pip报错,Unable to find resource t64.exe in package pip._vendor.distlib

升级pip出现错误不是很奇怪,但解决方法很神奇,收藏一下。
python -m pip install --upgrade --no-cache-dir pip
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: pip in c:\users\admin\appdata\roaming\python\python310\site-packages (24.0)
Collecting pip
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ef/7d/500c9ad20238fcfcb4cb9243eede163594d7020ce87bd9610c9e02771876/pip-24.3.1-py3-none-any.whl (1.8 MB)
     ---------------------------------------- 1.8/1.8 MB 626.8 kB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 24.0
    Uninstalling pip-24.0:
      Successfully uninstalled pip-24.0
  Rolling back uninstall of pip
  Moving to c:\users\admin\appdata\roaming\python\python310\scripts\pip.exe
   from C:\Users\admin\AppData\Local\Temp\pip-uninstall-fkguui0m\pip.exe
  Moving to c:\users\admin\appdata\roaming\python\python310\scripts\pip3.10.exe
   from C:\Users\admin\AppData\Local\Temp\pip-uninstall-fkguui0m\pip3.10.exe
  Moving to c:\users\admin\appdata\roaming\python\python310\scripts\pip3.exe
   from C:\Users\admin\AppData\Local\Temp\pip-uninstall-fkguui0m\pip3.exe
  Moving to c:\users\admin\appdata\roaming\python\python310\site-packages\pip-24.0.dist-info\
   from C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\~ip-24.0.dist-info
  Moving to c:\users\admin\appdata\roaming\python\python310\site-packages\pip\
   from C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\~ip
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_internal\cli\req_command.py", line 245, in wrapper
    return func(self, options, args)
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_internal\commands\install.py", line 452, in run
    installed = install_given_reqs(
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_internal\req\__init__.py", line 72, in install_given_reqs
    requirement.install(
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_internal\req\req_install.py", line 856, in install
    install_wheel(
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_internal\operations\install\wheel.py", line 725, in install_wheel
    _install_wheel(
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_internal\operations\install\wheel.py", line 642, in _install_wheel
    generated_console_scripts = maker.make_multiple(scripts_to_generate)
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\distlib\scripts.py", line 451, in make_multiple
    filenames.extend(self.make(specification, options))
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_internal\operations\install\wheel.py", line 423, in make
    return super().make(specification, options)
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\distlib\scripts.py", line 440, in make
    self._make_script(entry, filenames, options=options)
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\distlib\scripts.py", line 339, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\distlib\scripts.py", line 260, in _write_script
    launcher = self._get_launcher('t')
  File "C:\Users\admin\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\distlib\scripts.py", line 419, in _get_launcher
    raise ValueError(msg)
ValueError: Unable to find resource t64.exe in package pip._vendor.distlib

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

(sdwebui) >python -m pip install --user --upgrade pip
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: pip in c:\users\admin\appdata\roaming\python\python310\site-packages (24.0)
Collecting pip
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ef/7d/500c9ad20238fcfcb4cb9243eede163594d7020ce87bd9610c9e02771876/pip-24.3.1-py3-none-any.whl (1.8 MB)
     ---------------------------------------- 1.8/1.8 MB 1.0 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 24.0
    Uninstalling pip-24.0:
      Successfully uninstalled pip-24.0
  WARNING: The scripts pip.exe, pip3.10.exe and pip3.exe are installed in 'C:\Users\admin\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-24.3.1

正常升级一直失败:python -m pip install --upgrade --no-cache-dir pip ,

更换为python -m pip install --user --upgrade pip 成功了。

使用 python -m pip install --user --upgrade pip 成功的原因主要有以下几点:

用户权限:--user 选项会将 pip 安装到用户目录,而不是全局系统目录。这样可以避免因为权限不足而导致的安装问题。
避免冲突:如果系统中有多个 Python 安装或 pip 版本,使用 --user 可以确保你正在更新用户环境中的 pip,而不是系统环境中的 pip,从而减少潜在的冲突。
环境隔离:将 pip 安装到用户目录可以避免与系统全局环境中的库发生冲突,特别是在一些权限受限的环境中。
简单安全:在没有管理员权限的情况下,使用 --user 选项是一个安全的选择,因为它不会影响其他用户的环境

参考:https://blog.csdn.net/poorlytechnology/article/details/110914472

猜你喜欢

PHP CURL POST请求返回 400 Bad Request的处理

某套代码,都是linux,只是换了一台,换了php环境。 运行CURL POST请求返回 400 Bad Request。 经过验证排查,原因虽然使用POST,但我们的参数是在URL后边拼接的。 解决...

alphaTab.js在播放gp5格式曲谱乱码的解决

alphaTab.js在播放gp5格式曲谱乱码的解决

alphaTab.js是一个用来实现在网页播放guitar pro曲谱的js框架,能够兼容甩有gp格式的在线播放,但是alphaTab.js在播放一年老曲谱的时候会出现汉字乱码。 这里的原因就是这个...