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?
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 .
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.
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.
There is a new open pip issue which deals with this problem.
The issue is closed as WONTFIX
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With