pip install 无法识别以前安装的包

pip install is not recognizing a previously installed package

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

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

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,当它不起作用时,我尝试返回到他们错误消息中提到的确切版本。

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

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

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

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

你能试试“--find-links”吗?

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

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

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

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

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

也许您还需要安装 wheel 软件包。在此处查看详细信息: