本文介绍了在Python中,`pip -r requirements.txt'不会*递归*安装软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python 3.5.1和pip 7.1.2:

I'm using Python 3.5.1 and pip 7.1.2:

pip3 --version
pip 7.1.2 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5)

在我的requirements.txt中,我写:

In my requirements.txt, I write:

pysam>=0.9.0

然后,我使用pip3来安装如下的requirements.txt文件:

Then I use pip3 to install this requirements.txt file like this:

pip3 install -U -r requirements.txt

pysam有其自己的依赖项:cython,可在以下位置查看: https://github.com/pysam-developers/pysam/blob/master/requirements.txt

This pysam has its own dependencies: cython, which can be seen at: https://github.com/pysam-developers/pysam/blob/master/requirements.txt

但是,使用pip3 install -U -r requirements.txt似乎不能递归安装pysam的依赖项,这会引发对ValueError: no cython installed的期望.

However, using pip3 install -U -r requirements.txt seems not to install pysam's dependency recursively, it will throw an expection that ValueError: no cython installed.

有人对为什么不递归安装requirements.txt的想法有什么想法吗?

Does anyone have ideas about why requirements.txt are not installed recursively?

推荐答案

pysam setup.py脚本似乎使用了requires而不是典型的install_requires;后者生成pip确定其需求所需的元数据.实际上,pysam似乎需要cython来构建自身,因此更合适的是,它应该使用setup_requires.如果您未安装cython,则可以检查pysam的安装是否能正常进行.

The pysam setup.py script seems to use requires instead of the typical install_requires; the latter generates the metadata that pip needs to figure out its requirements. In fact, pysam seems to need cython in order to build itself, so more appropriately, it should be using setup_requires. You can check that installing pysam fails the normal way if you don't have cython installed.

(不起作用)无论如何,您都可以通过在您的需求文件中将cython放在pysam之前来解决此问题;这样,pip将尝试在pysam上移动之前安装cython:

(edit: DOES NOT WORK)In any case, you can get around this by placing cython before pysam in your requirements file; that way, pip will try to install cython before it moves on the pysam:

cython>=0.22
pysam>=0.9.0

编辑:请注意,这与pip -r requirements.txt本身无关.这是因为pip从pysam接收到的元数据不足,无法知道需要先安装cython才能尝试安装pysam.

Edit: to be clear, this has nothing to do with pip -r requirements.txt itself. It's that pip doesn't receive enough metadata from pysam to know that it needs to install cython first before trying to install pysam.

第二次修改:您是对的.安装仍然会失败,因为pip会先尝试从pysam安装脚本获取元数据,然后再进入构建阶段,如果未安装cython,则pysam安装脚本会抛出该错误.在这种情况下,除了预先在单独的命令中安装Cython之外,我不确定是否有解决方案.

Second edit: You're right. The installation still fails because pip tries to get the metadata from the pysam setup script before it moves on to the build stage, and the pysam setup script throws that error if cython isn't installed. In this specific case, I'm not sure there's a solution beyond installing Cython in a seperate command, beforehand.

这篇关于在Python中,`pip -r requirements.txt'不会*递归*安装软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 07:11