Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
628 views
in Technique[技术] by (71.8m points)

python - pip fails to install packages from requirements.txt

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

... 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: I am using pip v1.1 and python v2.7.2 with virtualenv and virtualenvwrapper

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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.

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.

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.

More info here: https://github.com/pypa/pip/issues/25


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...