Installed Python libraries scipy and matplotlib but can't import

Viewed 10420

I'm using python 3.4.2, and I believe I downloaded it from python.org. I'm running this on a Mac with El Capitan.

I tried downloading scipy using the anaconda's graphic installation interface. After running the installer, I opened IDLE and tried:

>>> import scipy

But got the error:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import scipy
ImportError: No module named 'scipy'

I tried the same thing with numpy, but got the same error.

I then tried installing matplotlib, but this time I figured I should try using pip on the command line. First I tried:

dhcp-wifi-8021x-155-41-121-77:~ theMAN$ pip install matplotlib
Requirement already satisfied: matplotlib in 
./anaconda/lib/python3.6/site-packages
Requirement already satisfied: numpy>=1.7.1 in 
./anaconda/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: six>=1.10 in 
./anaconda/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: python-dateutil in 
./anaconda/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: pytz in ./anaconda/lib/python3.6/site-
packages (from matplotlib)
Requirement already satisfied: cycler>=0.10 in 
./anaconda/lib/python3.6/site-packages (from matplotlib)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 
in ./anaconda/lib/python3.6/site-packages (from matplotlib)

But trying to import scipy, numpy, and matplotlib still returned the same errors. I also tried uninstalling and reinstalling scipy with pip, but that didn't change anything.

Are the modules not installing properly? Are they installed but I'm not importing them right?

3 Answers

TiarnĂ¡n de Burca's comment helped but just one more step afterwards.

When you find the path python2.7 expects the install you can install directly to this directory with pip.

sudo pip install scipy -t <path-to-directory>

Beware I'm working over a vpn on a raspberry pi and the download took eons be patient open a screen if you have a similar situation but this solved my problem finally.

Update: I jumped the gun the build failed though it looked like it was working. This worked. https://github.com/scipy/scipy/blob/master/INSTALL.rst.txt#installing-scipy

For ubuntu/debian run these first if you don't have them installed already:

sudo apt-get install libatlas-base-dev
pip install cython

I've also read miniconda is a workaround that does not require compiling.

Related