Osk*_*son 11 python packages pip
我正在尝试设置一个本地目录,其中的软件包可以在没有互联网连接的机器上重新安装,但是我遇到了一些软件包的问题.
我首先下载包
pip download -r requirements.txt -d my_packages --no-binary :all:
Run Code Online (Sandbox Code Playgroud)
然后我尝试安装它们
pip install -r requirements.txt --no-index -f my_packages
Run Code Online (Sandbox Code Playgroud)
我在安装时遇到的一个软件包是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
Run Code Online (Sandbox Code Playgroud)
当然,setuptools我可以手动安装,但所有其他软件包所需的软件包数量更多.django-guardian==1.4.9是另一个例子,需要pytest-runner由于某种原因不下载pip download
使用pip wheel而不是pip download来预下载并编译您的依赖项。
$ 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
Run Code Online (Sandbox Code Playgroud)
pip wheel会生成python-dateutil软件包,因此setuptools_scm以后不需要pip install。
根据文档,
Wheel是一种内置软件包格式,其优点是不会在每次安装时重新编译软件。
因此,我推测这pip wheel将使用构建时依赖性,例如setuptools_scm,但pip install不会,因为.whl已经构建了。
该--no-binary :all:选项仍然做正确的事情:下载源代码.tar.gz而不是任何二进制发行版。
(jwodder精明地指出了运行时依赖关系(即) install_requires和构建时依赖关系(即 setup_requires)之间的差异。)
我在本地环境上进行了测试,没有setuptools_scm,没有pytest-runner,没有问题。
(py3) j@computer:~/so-examples|? pip freeze
django-guardian==1.4.9
python-dateutil==2.7.3
six==1.11.0
Run Code Online (Sandbox Code Playgroud)
由于您指定了--no-binary :all:,pip 仅下载软件包的 sdists,而不会下载任何轮子。然而,PIP仍需轮形式每包当谈到时间来安装,所以pip install尝试构建每个包从sdist车轮,这一步需要setuptools,wheel以及在包装上市什么setup_requires。我不知道为什么你的环境没有setuptools,但任何健康的 Python 环境都应该同时wheel安装它,并在创建环境时安装。
不幸的是, 中列出的包setup_requires是setuptools自己安装的,而不是 pip安装的,因此pip download无法捕获这些要求。如果您坚持使用--no-binary :all:,那么唯一的解决方案是手动编译pip install运行时丢失的软件包列表,下载它们,然后要么在依赖它们的软件包之前安装丢失的软件包,要么配置 setuptools 以查找下载在my_packages。幸运的是,该列表可能会很短(可能只有pytest-runner和setuptools_scm)。
| 归档时间: |
|
| 查看次数: |
3625 次 |
| 最近记录: |