我正在尝试使用需求文件安装python软件。
>> 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
所以我创建了一个虚拟环境
>> mkvirtualenv parser
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
(parser)
>> pip install -r requirements.txt
..。然后我下载了软件包,但没有安装,并出现错误:http://pastie.org/4079800
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
令人惊讶的是,如果我尝试手动安装每个包,它们都安装得很好。例如:
>> pip install numpy==1.6.1
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
numpy==1.6.1
我迷路了。怎么一回事?
PS:我使用的是带有virtualenv
和virtualenvwrapper
的pip
v1.1和python
v2.7.2
发布于 2012-06-13 21:29:10
看起来numexpr
包在安装时依赖于numpy。Pip对您的需求进行了两次遍历:首先它下载所有包并运行每个包的setup.py
以获取其元数据,然后在第二次遍历中安装所有包。
因此,numexpr试图在其setup.py中从numpy导入,但是当pip第一次运行numexpr的setup.py时,它还没有安装numpy。
这也是为什么您在逐个安装软件包时看不到此错误的原因:如果您一次安装一个软件包,那么在pip install
numexpr之前,numpy将在您的环境中完全安装。
惟一的解决方案是在运行pip install -r requirements.txt
之前安装pip install numpy
--您不能使用单个requirements.txt文件在单个命令中执行此操作。
更多信息请点击此处:https://github.com/pypa/pip/issues/25
发布于 2021-12-24 01:14:41
这有时是相当恼人的,一个pip的bug。当您运行pip install package_name时,pip将首先对目标包运行pip check,然后安装依赖项(目标包)所需的所有包。但是当你运行pip install时,-r requirements.txt pip会尝试直接安装所有需要的包,从上到下逐个列出。有时,依赖项列在它所依赖的包的上方。
The solution is simple:
1.pip install package_name
2.simply put the error package to the bottom of the requirements.txt
3.sometimes a particular version of the package is not be able to be installed,just install the newest version of it and update the data in requirements.txt
https://stackoverflow.com/questions/11015692
复制相似问题