简体   繁体   English

在Python中,`pip -r requirements.txt`不会递归地安装包*?

[英]In Python, `pip -r requirements.txt` doesn't install packages *recursively*?

I'm using Python 3.5.1 and pip 7.1.2: 我正在使用Python 3.5.1和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)

In my requirements.txt, I write: 在我的requirements.txt中,我写道:

pysam>=0.9.0

Then I use pip3 to install this requirements.txt file like this: 然后我使用pip3来安装这个requirements.txt文件,如下所示:

pip3 install -U -r requirements.txt

This pysam has its own dependencies: cython , which can be seen at: https://github.com/pysam-developers/pysam/blob/master/requirements.txt 这个pysam有自己的依赖: cython ,可以在以下网址看到: https//github.com/pysam-developers/pysam/blob/master/requirements.txt

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 . 但是,使用pip3 install -U -r requirements.txt似乎不会递归地安装pysam的依赖,它会抛出一个ValueError: no cython installed

Does anyone have ideas about why requirements.txt are not installed recursively ? 有没有人有关于为什么不以递归方式安装requirements.txt想法?

The pysam setup.py script seems to use requires instead of the typical install_requires ; 该pysam setup.py脚本似乎使用requires ,而不是典型的install_requires ; the latter generates the metadata that pip needs to figure out its requirements. 后者生成pip需要的元数据以确定其要求。 In fact, pysam seems to need cython in order to build itself, so more appropriately, it should be using setup_requires . 事实上,pysam似乎需要cython来构建自己,所以更合适的是,它应该使用setup_requires You can check that installing pysam fails the normal way if you don't have cython installed. 如果没有安装cython,可以检查安装pysam是否正常运行。

(edit: DOES NOT WORK) In any case, you can get around this by placing cython before pysam in your requirements file; (编辑:不工作)无论如何,你可以通过在你的需求文件中放置pysam之前的cython来解决这个问题; that way, pip will try to install cython before it moves on the pysam: 这样,pip将尝试在pysam移动之前安装cython:

cython>=0.22
pysam>=0.9.0

Edit : to be clear, this has nothing to do with pip -r requirements.txt itself. 编辑 :要清楚,这与pip -r requirements.txt本身无关。 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接收到足够的元数据,因此在尝试安装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. 安装仍然失败,因为pip在进入构建阶段之前尝试从pysam安装脚本获取元数据,并且如果未安装cython,则pysam安装脚本会抛出该错误。 In this specific case, I'm not sure there's a solution beyond installing Cython in a seperate command, beforehand. 在这种特殊情况下,我不确定除了预先在单独的命令中安装Cython之外还有一个解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM