并非所有依赖项都通过"pip download"下载. [英] All dependencies are not downloaded with "pip download"
问题描述
我正在尝试建立一个本地目录,其中包含可以在没有互联网连接的机器上重复使用的软件包,但是我遇到了某些软件包的问题.
I'm trying to setup a local directory with packages that can be reused for installation on a machine without an internet connection but I'm having problems with some of the packages.
我首先使用
pip download -r requirements.txt -d my_packages --no-binary :all:
然后我尝试使用
pip install -r requirements.txt --no-index -f my_packages
我无法安装的软件包之一是elasticsearch-dsl==6.1.0
:
One of the packages I'm having trouble installing is elasticsearch-dsl==6.1.0
:
pip install -r requirements --no-index -f my_packages
Looking in links: my_packages
Collecting elasticsearch-dsl==6.1.0
Collecting six (from elasticsearch-dsl==6.1.0)
Collecting python-dateutil (from elasticsearch-dsl==6.1.0)
Installing build dependencies ... error
Complete output from command /Users/Oskar/.pyenv/versions/2.7.15/envs/no_internet/bin/python2.7 -m pip install --ignore-installed --no-user --prefix /private/var/folders/36/t0_t6_td2f560t2j0149vjmw0000gn/T/pip-build-env-moib0N --no-warn-script-location --no-binary :none: --only-binary :none: --no-index --find-links my_packages -- setuptools wheel:
Looking in links: my_packages
Collecting setuptools
Could not find a version that satisfies the requirement setuptools (from versions: )
No matching distribution found for setuptools
当然可以,setuptools
我可以手动安装,但是比所有其他软件包都需要的软件包要多. django-guardian==1.4.9
是另一个需要pytest-runner
的示例,出于某些原因,pytest-runner
并未随pip download
Sure, setuptools
I can manually install but there is more packages than that which is required for all the other packages. django-guardian==1.4.9
is another example which requires pytest-runner
which for some reason is not downloaded with pip download
推荐答案
使用pip wheel
而不是pip download
来预下载并编译您的依赖项.
Use pip wheel
, instead of pip download
, to pre-download and compile your dependencies.
$ pip install wheel
$ pip wheel -w my_wheels python-dateutil --no-binary :all:
$ pip install -f my_wheels --no-index python-dateutil # works
$ pip install -f my_packages --no-index python-dateutil # breaks
pip wheel
生成python-dateutil
程序包,因此以后在pip install
期间不需要setuptools_scm
.
pip wheel
builds the python-dateutil
package, so you don't need setuptools_scm
later during pip install
.
根据文档
车轮是一种内置包装格式,具有以下优点: 在每次安装期间重新编译软件.
Wheel is a built-package format, and offers the advantage of not recompiling your software during every install.
因此,我猜想pip wheel
将使用诸如setuptools_scm
之类的构建时依赖项,但由于已构建.whl
,因此pip install
不会使用.
Therefore, I surmise that pip wheel
will use build-time dependencies, such as setuptools_scm
, but pip install
won't, since the .whl
has been built.
--no-binary :all:
选项仍然可以执行正确的操作:将源代码下载到.tar.gz
中,而不是下载任何二进制发行版.
The --no-binary :all:
option still does the right thing: downloads the source in .tar.gz
instead of any binary distributions.
(jwodder精明地指出了运行时相关性即 install_requires
与构建时相关性即 setup_requires
之间的差异.)
(jwodder was shrewd in pointing out the differences between run-time dependencies i.e. install_requires
and build-time dependencies i.e. setup_requires
.)
我在本地环境中进行了测试,没有setuptools_scm
也没有pytest-runner
,没问题.
I tested this on a local environment, and no setuptools_scm
and no pytest-runner
, no problem.
(py3) j@computer:~/so-examples|⇒ pip freeze
django-guardian==1.4.9
python-dateutil==2.7.3
six==1.11.0
这篇关于并非所有依赖项都通过"pip download"下载.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!