問題描述
我正在嘗試使用需求文件安裝 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
所以我創(chuàng)建了一個虛擬環(huán)境
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
我迷路了.怎么回事?
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
以獲取其元數(shù)據(jù),然后在第二遍中安裝它們.
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 導(dǎo)入,但是當(dāng) 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.
這也是你一個一個安裝包時看不到這個錯誤的原因:如果你一次安裝一個,numpy會在你pip install
數(shù)字表達式.
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
這篇關(guān)于pip 無法從 requirements.txt 安裝軟件包的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!