Skip to content Skip to sidebar Skip to footer

Matplotlib Requirements With Pip Install In Virtualenv

I have a requirements.txt file like this: numpy matplotlib When I try pip install -r requirements.txt inside a new virtualvenv, I get this: REQUIRED DEPENDENCIES num

Solution 1:

Matplotlib and pip don't seem to play together very well. So I don't think it is possible in this case.

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.

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).

This was once addressed in pip issue #24 and issue #25. The issues are closed but give some more details.

What I am doing up to now is to first install numpy and than install all packages from my requirements file.

Update 12/2012

There is a new open pip issue which deals with this problem.

Update 04/2013

The issue is closed as WONTFIX

Solution 2:

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.

Solution 3:

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:

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.

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?

Solution 4:

After playing with pip lately i realized that requirements file should be rearranged manually, preferably while generating it.

In simple case (i.e. just numpy and matplotlib requires ordering), you can just reverse requrements file: pip freeze | sort -r

Solution 5:

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.

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.

Post a Comment for "Matplotlib Requirements With Pip Install In Virtualenv"