Wednesday, February 27, 2013

pip install numpy and scipy together

    While working for a new python module at +Salford Systems, I've discovered an issue if you run command like this:
https://github.com/scipy/scipy
 pip install numpy scipy 
...
 ".tox/py25/build/scipy/setup.py", line 131, in setup_package from numpy.distutils.core import setup  ImportError: No module named numpy.distutils.core 
    Same issue will appear if numpy and scipy modules are listed in requirements.txt and you will try to install it as:
pip install -r requirements.txt 
 The origin of issue is that setup.py in scipy is using numpy.distrutils.core.setup and doesn't want to work with it, but pip actually queries setup.py with egg_info before installing anything. This is done to prevent installing broken packages and leaving half-installed state. Instead it checks first that everything fine and only then starts to install them.

     Now, I've made my our branch of scipy on github and fixed this by making whitelist of commands that are able to work without numpy importing. This allows to run listed above examples without issues.
     Pending pull-request to master of scipy is here - https://github.com/scipy/scipy/pull/453

     PS. Related issues on a web:
http://projects.scipy.org/scipy/ticket/1429pypa/pip#25pypa/pip#272sjsrey/pysal#207http://bb10.com/python-testing-general/2011-06/msg00028.html