1

I just installed scipy and numpy using homebrew and pip. I did the following:

brew install python
brew install gfortran
easy_install pip
sudo pip install numpy
sudo pip install scipy

numpy and scipy are both easily found in /Library/Python/2.7/site-packages, but when I open a python shell in the terminal and type:

import numpy
import scipy

I get:

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: No module named numpy

and the same for scipy. What's wrong? Pip seems to think they're installed.

2
  • 3
    are you sure that python you are using is the same as the python for which numpy and scipy are installed ? Commented Jul 17, 2012 at 7:14
  • After you install python with homebrew, it tells you to add some paths to your PATH and PYTHONPATH. If you don't do that, easy_install and thus pip will be the system python's, not homebrew's. numpy and scipy should be installed in /usr/local/... for homebrew's python to find it. Commented Jul 17, 2012 at 14:06

2 Answers 2

2

The python shell you are running from the terminal is probably OSX pre-bundled python and not the one you installed (with numpy & scipy).

You can list the current paths using:

import sys
print(sys.path)
Sign up to request clarification or add additional context in comments.

Comments

1

It might be a bit overkill, but I once wrote a short guide to install Python 2.7.x in OS X. You can find it here.

The bottom line is that right now you might have two versions of Python installed, and it can be a bit tricky to uninstall only one of them. If you're sure which one is using the right site-packages folder, then delete the other and update your path variables. If not, I'd suggest to follow that guide.

1 Comment

It looks like you're right, I have two pythons. One is the original that came with my mac, and one is the one homebrew installed in /usr/local. When I type which python I get /usr/local/bin/python, which is the brew install. But as I said above, numpy and scipy are installed with the osx install (I probably didn't edit the path properly and pip installed it wrong. Is this a quick fix by moving some things around, or do I need to reinstall?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.