【问题标题】:pip install is not recognizing a previously installed packagepip install 无法识别以前安装的软件包
【发布时间】:2021-01-14 02:24:48
【问题描述】:

我正在尝试为项目创建标准虚拟环境。我有一个包含所有必需模块的工作虚拟环境。我有一个批处理文件来安装所需的东西。

部分批处理代码如下所示:

pip install --no-index "altgraph-0.17-py2.py3-none-any.whl"
pip install --no-index "pefile-2017.8.1.zip"
pip install --no-index "pywin32_ctypes-0.2.0-py2.py3-none-any.whl"

pip install --no-index "setuptools-40.8.0-py2.py3-none-any.whl "
pip install --no-index "PyInstaller-3.6.tar.gz"

当我运行它时,我收到以下错误:

(py368) C:\Users\kgreen\Source\Repos\MapTools\py368_modules>pip install --no-index "PyInstaller-3.6.tar.gz"
Processing c:\users\kgreen\source\repos\maptools\py368_modules\pyinstaller-3.6.tar.gz
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\kgreen\source\repos\maptools\py368\scripts\python.exe' 'c:\users\kgreen\source\repos\maptools\py368\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\kgreen\AppData\Local\Temp\pip-build-env-fcj_djos\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: --no-index -- 'setuptools>=40.8.0' wheel
       cwd: None
  Complete output (2 lines):
  ERROR: Could not find a version that satisfies the requirement setuptools>=40.8.0
  ERROR: No matching distribution found for setuptools>=40.8.0
  ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\kgreen\source\repos\maptools\py368\scripts\python.exe' 'c:\users\kgreen\source\repos\maptools\py368\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\kgreen\AppData\Local\Temp\pip-build-env-fcj_djos\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: --no-index -- 'setuptools>=40.8.0' wheel Check the logs for full command output.

但这正是我安装的 setuptools 的版本!我之前尝试过 setuptools-41.4.0,但当它不起作用时,我尝试返回到错误消息中提到的确切版本。

注意:我稍后尝试安装 gazpacho 时遇到同样的错误...无法识别 setuptools>=40.8.0 已安装。

注意:当我做 pip list 时,我看到确实安装了正确版本的 setuptools。

(编辑)注意:我忘了提到这也必须适用于未连接到 Internet 的系统,因此解决方案必须指向轮文件或 zip,但不能直接指向 PyPi。

我还尝试在事后手动输入安装,认为可能需要延迟才能完成对 setuptools 先前安装的一些处理。 (也许很傻,但我很绝望。) 为什么看不到那个版本?我该如何解决这个问题?

【问题讨论】:

    标签: python pip setuptools


    【解决方案1】:

    我在尝试安装 atlassian-python-api 时遇到了同样的问题。 如果尝试离线安装软件包(带有--no-index 标志),看起来它是 pip (从版本 10 开始)的问题。 我在 PyInstaller github 上找到了解决方案: https://github.com/pyinstaller/pyinstaller/issues/4557#issuecomment-569450071 (“PEP517 建议应该在 pip 使用 --ignore-installed 完成的隔离环境中完成包构建”)

    所以只需在 pip 命令中添加--no-build-isolation 标志:

    pip install --no-index --find-links "PyInstaller-3.6.tar.gz" --no-build-isolation
    

    也许您还需要安装wheel 软件包。在此处查看详细信息: Why is python setup.py saying invalid command 'bdist_wheel' on Travis CI?

    【讨论】:

      【解决方案2】:

      你可以试试“--find-links”吗?

      pip install --no-index --find-links "PyInstaller-3.6.tar.gz"
      

      这意味着安装您的本地包并从 pypi 安装其他所需的包。如果你的 pip install a "setuptools-40.8.0" 成功,你的错。但是忽略安装setuptools,可能有些包坏了。

      【讨论】:

      • 我会尝试查找链接。我特别需要从 whl 或 zip 文件安装,因为这也必须适用于未连接到 Internet 的系统。我的错。我把它排除在我的问题定义之外。
      猜你喜欢
      • 2014-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-07
      • 2017-07-27
      • 1970-01-01
      • 2021-11-19
      • 1970-01-01
      相关资源
      最近更新 更多