我正在尝试将paramiko的依赖项从linux主机下载到无法访问Internet的Windows目标。
阅读pip's documentation上的示例后,我习惯使用以下命令将递归依赖性下载到64位Windows平台:
pip3 download --only-binary=:all: --platform win_amd64 --implementation cp paramiko
能够递归下载依赖项,直到达到pycparser。这并不奇怪,因为我使用了--only-binary =:all:flag。事情是 - 当传递--platform标志时,pip强制使用这个标志:
ERROR: --only-binary=:all: must be set and --no-binary must not be set (or must be set to :none:) when restricting platform and interpreter constraints using --python-version, --platform, --abi, or --implementation.
终端产生了以下输出:
Collecting paramiko
Downloading paramiko-2.3.0-py2.py3-none-any.whl (182kB)
100% |████████████████████████████████| 184kB 340kB/s
Saved ./paramiko-2.3.0-py2.py3-none-any.whl
Collecting pynacl>=1.0.1 (from paramiko)
Using cached PyNaCl-1.1.2-cp35-cp35m-win_amd64.whl
Saved ./PyNaCl-1.1.2-cp35-cp35m-win_amd64.whl
Collecting cryptography>=1.5 (from paramiko)
Using cached cryptography-2.0.3-cp35-cp35m-win_amd64.whl
Saved ./cryptography-2.0.3-cp35-cp35m-win_amd64.whl
Collecting pyasn1>=0.1.7 (from paramiko)
Using cached pyasn1-0.3.5-py2.py3-none-any.whl
Saved ./pyasn1-0.3.5-py2.py3-none-any.whl
Collecting bcrypt>=3.1.3 (from paramiko)
Using cached bcrypt-3.1.3-cp35-cp35m-win_amd64.whl
Saved ./bcrypt-3.1.3-cp35-cp35m-win_amd64.whl
Collecting cffi>=1.4.1 (from pynacl>=1.0.1->paramiko)
Using cached cffi-1.11.0-cp35-cp35m-win_amd64.whl
Saved ./cffi-1.11.0-cp35-cp35m-win_amd64.whl
Collecting six (from pynacl>=1.0.1->paramiko)
Using cached six-1.11.0-py2.py3-none-any.whl
Saved ./six-1.11.0-py2.py3-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography>=1.5->paramiko)
Using cached asn1crypto-0.22.0-py2.py3-none-any.whl
Saved ./asn1crypto-0.22.0-py2.py3-none-any.whl
Collecting idna>=2.1 (from cryptography>=1.5->paramiko)
Using cached idna-2.6-py2.py3-none-any.whl
Saved ./idna-2.6-py2.py3-none-any.whl
Collecting pycparser (from cffi>=1.4.1->pynacl>=1.0.1->paramiko)
Could not find a version that satisfies the requirement pycparser (from cffi>=1.4.1->pynacl>=1.0.1->paramiko) (from versions: )
No matching distribution found for pycparser (from cffi>=1.4.1->pynacl>=1.0.1->paramiko)
有没有办法克服这个问题?我是否必须手动安装非二进制包(及其依赖项)?
谢谢, 乔伊。
答案 0 :(得分:0)
您有两个选择:
不要尝试其他奇特的方法,否则您将陷入困境:一些依赖项需要编译!
答案 1 :(得分:0)
您可以在点子中使用--prefer-binary
选项。即使它们是比现有sdist较旧的版本(sdist是源代码发布的缩写),这也会使pip认为wheel更为重要。如果未找到兼容的车轮,则将选择sdist。
此版本在pip 18.0中发布(所以是2018年初,pip现在正在使用CalVer)。
答案 2 :(得分:-3)
在python3中,您可以下载如下所述的依赖项
在运行此文件时,将其保存在要保存的文件夹中
pip download -r requirements.txt
下载完文件后,将其移至您要安装的计算机上
然后运行此命令
pip install -r req.txt --no-index --find-links="/path/to/downloaded/files"