pip无法从requirements.txt安装软件包 [英] pip fails to install packages from requirements.txt
问题描述
我正在尝试使用需求文件安装python软件.
I am trying to install a python software using the requirements file.
>> cat requirements.txt
Cython==0.15.1
numpy==1.6.1
distribute==0.6.24
logilab-astng==0.23.1logilab-common==0.57.1
netaddr==0.7.6
numexpr==2.0.1
ply==2.5
pycallgraph==0.5.1
pyflowtools==0.3.4.1
pylint==0.25.1
tables==2.3.1
wsgiref==0.1.2
所以我创建了一个虚拟环境
So I create a virtual environment
>> mkvirtualenv parser
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
(parser)
>> pip install -r requirements.txt
...,然后我下载了但未安装但出现错误的软件包: http://pastie.org/4079800
... and then I packages downloaded but not installed with errors: http://pastie.org/4079800
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
令人惊讶的是,如果我尝试手动安装每个软件包,它们的安装就可以了. 例如:
Surprisingly, if I try to manually install each package, they install just fine. For instance:
>> pip install numpy==1.6.1
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
numpy==1.6.1
我迷路了.发生了什么事?
I am lost. What is going on?
PS:我正在将pip
v1.1和python
v2.7.2与virtualenv
和virtualenvwrapper
PS: I am using pip
v1.1 and python
v2.7.2 with virtualenv
and virtualenvwrapper
推荐答案
看来numexpr
软件包对numpy具有安装时依赖性. Pip进行了两次遍历您的要求:首先下载所有软件包并运行每个软件包的setup.py
以获取其元数据,然后在第二遍将它们全部安装.
It looks like the numexpr
package has an install-time dependency on numpy. Pip makes two passes through your requirements: first it downloads all packages and runs each one's setup.py
to get its metadata, and then it installs them all in a second pass.
因此,numexpr尝试从其setup.py中的numpy导入,但是当pip首次运行numexpr的setup.py时,尚未安装numpy.
So, numexpr is trying to import from numpy in its setup.py, but when pip first runs numexpr's setup.py, it has not yet installed numpy.
这也是为什么在逐个安装软件包时看不到此错误的原因:如果一次安装一个软件包,则在您pip install
numexpr之前,numpy将完全安装在您的环境中.
This is also why you don't see this error when you install the packages one by one: if you install them one at a time, numpy will be fully installed in your environment before you pip install
numexpr.
唯一的解决方案是在运行pip install -r requirements.txt
之前先安装pip install numpy
-您将无法在单个命令中使用单个requirements.txt文件来完成此操作.
The only solution is to install pip install numpy
before you ever run pip install -r requirements.txt
-- you won't be able to do this in a single command with a single requirements.txt file.
此处的更多信息: https://github.com/pypa/pip/issues/25
这篇关于pip无法从requirements.txt安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!