Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scipy installation issues from source?

I'm trying to install scipy numpy from source for installing scikit learn from source. I managed to do it for numpy and scikit but for scipy I get an error,

ImportError: No module named numpy.distutils.core

This is happening because numpy is not install in the site-packages directory for python, but in a custom directory. Any workaround this?

like image 666
gizgok Avatar asked Oct 20 '22 20:10

gizgok


1 Answers

The point of installing to a custom "home" is that you want to make that part of your sys.path. While you can do that by cding into that directory and starting Python (because . is part of the default sys.path), that's rarely a good idea. What you probably want to do is set a PYTHONPATH env variable, or extend your per-user site-packages, or something like that.

Or, even more simply, install into your system or user site-packages in the first place.

Or, if you don't want to pollute your global Python for whatever reason, use a virtualenv.

(While we're at it, it's easier to build things with pip than to manually find and download the tarballs, expand them, and run the setup.py. But that's a whole other issue.)

Let's say you want to do things this way for some reason. All you need to do is to get numpy onto sys.path while you're building scipy. For example:

$ PYTHONPATH="homepath" python setup.py install --home="homepath"

You may want to test this first:

$ PYTHONPATH="homepath" python
>>> import numpy
like image 104
abarnert Avatar answered Oct 23 '22 10:10

abarnert