I have a requirements.txt file like this:
我有一个这样的requirements.txt文件:
numpy
matplotlib
When I try pip install -r requirements.txt
inside a new virtualvenv, I get this:
当我在新的virtualvenv中尝试pip install -r requirements.txt时,我得到了这个:
REQUIRED DEPENDENCIES
numpy: no
* You must install numpy 1.1 or later to build
* matplotlib.
If I install numpy first and matplotlib after, it works. However I'd like to keep using pip install -r requirements.txt
. Is it possible?
如果我先安装numpy和matplotlib,它就可以了。但是我想继续使用pip install -r requirements.txt。可能吗?
6 个解决方案
#1
21
Matplotlib and pip don't seem to play together very well. So I don't think it is possible in this case.
Matplotlib和pip似乎并没有很好地结合在一起。所以我认为在这种情况下不可能。
pip
first downloads a package listed in your requirements file and than runs setup.py
, but it doesn't really install it (I'm not quite sure about the internals of pip
). After all packages are prepared in this way, they are installed.
pip首先下载你的需求文件中列出的一个包,然后运行setup.py,但它并没有真正安装它(我不太确定pip的内部)。以这种方式准备好所有包之后,就会安装它们。
The problem is, that matplotlib
checks if numpy
is installed in its setup.py
(the check itself is defined in setupext.py
). So at the moment the check is performed, numpy
is not installed and the matplotlib setup.py
exits with the error message you received (This may not be a bug, as it may require numpy to build).
问题是,matplotlib检查是否在其setup.py中安装了numpy(检查本身在setupext.py中定义)。所以在执行检查的那一刻,没有安装numpy并且matplotlib setup.py退出并收到您收到的错误消息(这可能不是一个错误,因为它可能需要numpy来构建)。
This was once addressed in pip issue #24 and issue #25. The issues are closed but give some more details.
这曾经在pip问题#24和问题#25中得到解决。问题已经结束,但提供了更多细节。
What I am doing up to now is to first install numpy and than install all packages from my requirements file.
我现在要做的是首先安装numpy,然后安装我的需求文件中的所有包。
Update 12/2012
There is a new open pip issue which deals with this problem.
有一个新的开放式点子问题可以解决这个问题。
Update 04/2013
The issue is closed as WONTFIX
该问题已作为WONTFIX关闭
#2
10
It's a known problem of the library and it's currently being discussed as a Matplotlib enhancement proposal: https://github.com/matplotlib/matplotlib/wiki/MEP11. Until it's fixed the only solution I can imagine is repackaging the library to remove the numpy check.
这是库的一个已知问题,目前正在讨论它作为Matplotlib增强提议:https://github.com/matplotlib/matplotlib/wiki/MEP11。在它修复之前,我能想象的唯一解决方案是重新打包库以删除numpy检查。
#3
1
Yes. "requirements.txt" is just a flat file from which pip can use to install packages. In that file, you can change the version of the dependencies. For example, it looks like you need at least 1.1, so try changing the line with 'numpy' to be:
是。 “requirements.txt”只是一个平面文件,pip可以用来安装包。在该文件中,您可以更改依赖项的版本。例如,看起来你需要至少1.1,所以尝试用“numpy”改变行:
numpy==1.1
Or, you can use >= like this:
或者,您可以使用> =这样:
numpy>=1.1
This may be what's holding you up. But, AFAIK, matplotlib should have a dependency on numpy already. Seems like that may need to be fixed.
这可能是什么阻碍了你。但是,AFAIK,matplotlib应该已经依赖于numpy了。似乎可能需要修复。
See also this How to pip install a package with min and max version range?
另请参见如何使用最小和最大版本范围来安装包?
and
In setup.py or pip requirements file, how to control order of installing package dependencies?
在setup.py或pip requirements文件中,如何控制安装包依赖项的顺序?
#4
0
After playing with pip lately i realized that requirements file should be rearranged manually, preferably while generating it.
在最近玩了pip后,我意识到需要手动重新安排需求文件,最好是在生成它时。
In simple case (i.e. just numpy
and matplotlib
requires ordering), you can just reverse requrements file: pip freeze | sort -r
在简单的情况下(即只需numpy和matplotlib需要订购),你可以反转请求文件:pip freeze |排序-r
#5
0
I've just gotten used to invoking a script to repeatably set up my virtualenv; it involves two requirements file: one with only numpy, and a second one with everything else.
我已经习惯了调用脚本来重复设置我的virtualenv;它涉及两个需求文件:一个只有numpy,另一个只有其他一切。
It's not a terrible thing to get used to, since pip will try to do 'all or nothing' when you install via a requirements file. This way, you can stage the installation so dependencies are installed first.
要习惯这不是一件可怕的事情,因为当你通过需求文件安装时,pip会尝试“全有或全无”。这样,您可以暂存安装,以便首先安装依赖项。
#6
0
I made it work in virtualenv inside an iPython notebook!
我在iPython笔记本中的virtualenv中工作了!
I have
ipython==2.2.0
numpy==1.8.2
matplotlib==1.4.2
It works in an iPython notebook with
它可以在iPython笔记本中使用
%matplotlib inline
from pylab import *
plot([1,2,3])
It does not work in an iPython console, though, but I am perfectly happy to do my graphing in the notebook!
但它在iPython控制台中不起作用,但我很高兴在笔记本中做我的图形!
At one point I was able to trick it into working from the console by installing some thing in the virtualenv, but other things only in the global namespace, but I forgot how I did it. I just kept installing and uninstalling things.
有一次,我能够通过在virtualenv中安装一些东西来欺骗它从控制台工作,但其他东西只在全局命名空间中,但我忘记了我是如何做到的。我只是不停地安装和卸载东西。
#1
21
Matplotlib and pip don't seem to play together very well. So I don't think it is possible in this case.
Matplotlib和pip似乎并没有很好地结合在一起。所以我认为在这种情况下不可能。
pip
first downloads a package listed in your requirements file and than runs setup.py
, but it doesn't really install it (I'm not quite sure about the internals of pip
). After all packages are prepared in this way, they are installed.
pip首先下载你的需求文件中列出的一个包,然后运行setup.py,但它并没有真正安装它(我不太确定pip的内部)。以这种方式准备好所有包之后,就会安装它们。
The problem is, that matplotlib
checks if numpy
is installed in its setup.py
(the check itself is defined in setupext.py
). So at the moment the check is performed, numpy
is not installed and the matplotlib setup.py
exits with the error message you received (This may not be a bug, as it may require numpy to build).
问题是,matplotlib检查是否在其setup.py中安装了numpy(检查本身在setupext.py中定义)。所以在执行检查的那一刻,没有安装numpy并且matplotlib setup.py退出并收到您收到的错误消息(这可能不是一个错误,因为它可能需要numpy来构建)。
This was once addressed in pip issue #24 and issue #25. The issues are closed but give some more details.
这曾经在pip问题#24和问题#25中得到解决。问题已经结束,但提供了更多细节。
What I am doing up to now is to first install numpy and than install all packages from my requirements file.
我现在要做的是首先安装numpy,然后安装我的需求文件中的所有包。
Update 12/2012
There is a new open pip issue which deals with this problem.
有一个新的开放式点子问题可以解决这个问题。
Update 04/2013
The issue is closed as WONTFIX
该问题已作为WONTFIX关闭
#2
10
It's a known problem of the library and it's currently being discussed as a Matplotlib enhancement proposal: https://github.com/matplotlib/matplotlib/wiki/MEP11. Until it's fixed the only solution I can imagine is repackaging the library to remove the numpy check.
这是库的一个已知问题,目前正在讨论它作为Matplotlib增强提议:https://github.com/matplotlib/matplotlib/wiki/MEP11。在它修复之前,我能想象的唯一解决方案是重新打包库以删除numpy检查。
#3
1
Yes. "requirements.txt" is just a flat file from which pip can use to install packages. In that file, you can change the version of the dependencies. For example, it looks like you need at least 1.1, so try changing the line with 'numpy' to be:
是。 “requirements.txt”只是一个平面文件,pip可以用来安装包。在该文件中,您可以更改依赖项的版本。例如,看起来你需要至少1.1,所以尝试用“numpy”改变行:
numpy==1.1
Or, you can use >= like this:
或者,您可以使用> =这样:
numpy>=1.1
This may be what's holding you up. But, AFAIK, matplotlib should have a dependency on numpy already. Seems like that may need to be fixed.
这可能是什么阻碍了你。但是,AFAIK,matplotlib应该已经依赖于numpy了。似乎可能需要修复。
See also this How to pip install a package with min and max version range?
另请参见如何使用最小和最大版本范围来安装包?
and
In setup.py or pip requirements file, how to control order of installing package dependencies?
在setup.py或pip requirements文件中,如何控制安装包依赖项的顺序?
#4
0
After playing with pip lately i realized that requirements file should be rearranged manually, preferably while generating it.
在最近玩了pip后,我意识到需要手动重新安排需求文件,最好是在生成它时。
In simple case (i.e. just numpy
and matplotlib
requires ordering), you can just reverse requrements file: pip freeze | sort -r
在简单的情况下(即只需numpy和matplotlib需要订购),你可以反转请求文件:pip freeze |排序-r
#5
0
I've just gotten used to invoking a script to repeatably set up my virtualenv; it involves two requirements file: one with only numpy, and a second one with everything else.
我已经习惯了调用脚本来重复设置我的virtualenv;它涉及两个需求文件:一个只有numpy,另一个只有其他一切。
It's not a terrible thing to get used to, since pip will try to do 'all or nothing' when you install via a requirements file. This way, you can stage the installation so dependencies are installed first.
要习惯这不是一件可怕的事情,因为当你通过需求文件安装时,pip会尝试“全有或全无”。这样,您可以暂存安装,以便首先安装依赖项。
#6
0
I made it work in virtualenv inside an iPython notebook!
我在iPython笔记本中的virtualenv中工作了!
I have
ipython==2.2.0
numpy==1.8.2
matplotlib==1.4.2
It works in an iPython notebook with
它可以在iPython笔记本中使用
%matplotlib inline
from pylab import *
plot([1,2,3])
It does not work in an iPython console, though, but I am perfectly happy to do my graphing in the notebook!
但它在iPython控制台中不起作用,但我很高兴在笔记本中做我的图形!
At one point I was able to trick it into working from the console by installing some thing in the virtualenv, but other things only in the global namespace, but I forgot how I did it. I just kept installing and uninstalling things.
有一次,我能够通过在virtualenv中安装一些东西来欺骗它从控制台工作,但其他东西只在全局命名空间中,但我忘记了我是如何做到的。我只是不停地安装和卸载东西。