在执行 pip3 install -r requirements.txt 命令时,如果遇到以下错误:

WARNING: Ignoring invalid distribution -ip (d:\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\anaconda\lib\site-packages)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pyminifier~=2.1
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/2c/8a/946b0b43e0912c907aba42507073675c2e4a4a836c5b1ce10be6f12575d0/pyminifier-2.1.tar.gz (47 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [3 lines of output]
      Python 3.X support requires the 2to3 tool.
      It normally comes with Python 3.X but (apparenty) not on your distribution.
      Please find out what package you need to get 2to3and install it.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
WARNING: Ignoring invalid distribution -ip (d:\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\anaconda\lib\site-packages)

这通常意味着 Python 3.X 支持需要 2to3 工具,但你的发行版中可能没有安装。

解决方案:

  1. 手动安装 2to3 工具:
    • 在大多数 Linux 发行版中,你可以使用包管理器(例如 apt, yum, dnf)来安装 python3-distutils 包。例如,在 Ubuntu 中,你可以使用以下命令:
      sudo apt install python3-distutils
      
    • 在 Windows 中,你可能需要安装 Python 3 的开发包,它通常包含 2to3 工具。
  2. 升级 pip:
    • 尝试升级 pip 到最新版本。使用以下命令:
      python3 -m pip install --upgrade pip
      
  3. 在 Python 2.x 环境下运行命令:
    • 如果你有多个 Python 版本,尝试在 Python 2.x 环境下运行 pip install -r requirements.txt 命令。

如果以上方法都无法解决问题,请尝试在搜索引擎中搜索更详细的解决方案或向社区寻求帮助。

pip3 install -r requirements.txt 错误:Python 3.X 需要 2to3 工具

原文地址: https://www.cveoy.top/t/topic/lyT7 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录