I'm running into the error discussed here when running setup.py: numpy 1.19.4 fails to install due to a windows bug. The current workaround is to use numpy 1.19.3 instead. However, I'm trying to run a setup.py file that doesn't list numpy directly as a dependency, but uses several packages that has numpy as a sub-dependency.
Because of this, I cannot directly pin numpy to 1.19.3. In this scenario, is there a simple way to get the install script working? In other words: how can I modify the setup.py file so that it won't install any package (versions) that has numpy 1.19.4 as a dependency?
The available dependency relations include !=
numpy!=1.19.4
I have a Python code that I have to send to my teacher. The issue is that I import the following packages :
import numpy as np
import matplotlib.pyplot as plt
import datetime as date
import ephem
I would like to create an archive .tar with my Python code inside but also all the necessary packages (numpy, matplotlib, datetime and the important ephem) to make the Python code running. Indeed, I am not sure that my teacher has all these packages installed on his computer.
Is it possible to perform this action in order to, for my teacher, unzip archive .tar and just do "python source.py" to get the code running without missing packages ?
The standard way would probably be to distribute a requirements.txt file that the pip command understands. i.e. you'd create the file containing:
numpy
matplotlib
ephem
and these would be installed by doing:
pip install -r requirements.txt
which would cause those packages to be installed. Note that you can include version numbers and other specifications in the requirements file if needed.
Note that we do this because installing packages like numpy can be non-trivial due to dependencies like BLAS which can be awkward to get configured under arbitrary OSs.
on 64bit win 7, I installed all of compatible versions of setuptools, numpy, python-dateutil, pytz, pyparsing and six in addition to matplotlib. I did this by downloading source into a folder, and installing from source ... for example,
python setup.py install
finally, I installed python matplotlib by,
cd matplotlib
python setup.py build
python setup.py install
I tested matplotlib by running python from my windows powershell, and typing import pylab I got error:
ImportError: error importing numpy: you should not try to import numpy from its source ...
I found a stackoverflow question that addressed this, leading answer was to change working directory from the directory where numpy lives.
I changed the working directory to another folder in my drive, again ran python from my interpreter, typed import pylab and received this error:
ImportError: NO module named numpy"
I am now at a loss. It either refuses to import numpy, or says it doesn't exist? But it knew it existed earlier?
Ive been looking for a solution for more than three hours now, am stumped. Apologies in advance if this question seems too noob.
finally, I am open to trying a different module if it would be easier. I only want to plot some data.
I'm trying to install scipy but when I finish installing, I can't import it. is there any GUI for easy installation? The general information:
Windows 7 - Python 2.7 - scipy 0.11.0 - I followed the steps in abel.ee.ucla.edu/cvxopt/install/index.html) for windows to install the libraries needed. I ran the setup for scipy using python setup.py install in command line and in the setup.py directory.
The error messege error link
If you are looking for a windows installer you can find one here: http://www.lfd.uci.edu/~gohlke/pythonlibs/
But as it says: These are unofficial, unsupported and you might have to reinstall numpy and everything depending on numpy from there too!
Read the instructions very careful!
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?
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
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.
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?
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
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.
I made it work in virtualenv inside an iPython notebook!
I have
ipython==2.2.0
numpy==1.8.2
matplotlib==1.4.2
It works in an iPython notebook with
%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!
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.