首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >pip无法从requirements.txt安装程序包

pip无法从requirements.txt安装程序包
EN

Stack Overflow用户
提问于 2012-06-13 21:17:40
回答 2查看 33.4K关注 0票数 26

我正在尝试使用需求文件安装python软件。

代码语言:javascript
复制
>> 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

所以我创建了一个虚拟环境

代码语言:javascript
复制
>> mkvirtualenv parser

(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2

(parser)
>> pip install -r requirements.txt

..。然后我下载了软件包,但没有安装,并出现错误:http://pastie.org/4079800

代码语言:javascript
复制
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2

令人惊讶的是,如果我尝试手动安装每个包,它们都安装得很好。例如:

代码语言:javascript
复制
>> pip install numpy==1.6.1

(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
numpy==1.6.1

我迷路了。怎么一回事?

PS:我使用的是带有virtualenvvirtualenvwrapperpip v1.1和python v2.7.2

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 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

票数 20
EN

Stack Overflow用户

发布于 2021-12-24 01:14:41

这有时是相当恼人的,一个pip的bug。当您运行pip install package_name时,pip将首先对目标包运行pip check,然后安装依赖项(目标包)所需的所有包。但是当你运行pip install时,-r requirements.txt pip会尝试直接安装所有需要的包,从上到下逐个列出。有时,依赖项列在它所依赖的包的上方。

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11015692

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档