Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib requirements with pip install in virtualenv

Tags:

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               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?

like image 336
msampaio Avatar asked Aug 03 '12 14:08

msampaio


People also ask

Do I need to install pip in VENV?

With the default settings, venv will install both pip and setuptools. Using pip is the recommended way to install packages in Python, and setuptools is a dependency for pip . Because installing other packages is the most common use case for Python virtual environments, you'll want to have access to pip .

What is pip in virtualenv?

pip is a tool for installing packages from the Python Package Index. virtualenv is a tool for creating isolated Python environments containing their own copy of python , pip , and their own place to keep libraries installed from PyPI.


2 Answers

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

like image 151
bmu Avatar answered Oct 22 '22 06:10

bmu


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.

like image 33
barracel Avatar answered Oct 22 '22 06:10

barracel