2

I've recently given up on macports and gone to homebrew. I'm trying to be able to import numpy and scipy. I seem to have installed everything correctly, but when I type python in terminal, it seems to run the default mac python.

I'm on OSX 10.8.4

I followed this post: python homebrew by default and tried to move the homebrew directory to the front of my %PATH by entering

export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH

then "echo $PATH" returns

/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin

however when I look for where my python is by "which python", I get

/usr/bin/python

For some reason when I import numpy in interpreter it works but not so for scipy.

Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named scipy
>>> 

What do I need to do to get python to run as my homebrew-installed python? Should this fix my problem and allow me to import scipy?

Community
  • 1
  • 1
Sammy
  • 669
  • 2
  • 8
  • 13
  • Your path when you echo $PATH does not reflect the previous command of putting /usr/local/bin first. – jrwren Aug 19 '13 at 12:40

1 Answers1

4

Homebrew puts things in a /usr/local/Cellar/<appname> directory, if I'm not mistaken. You should find the bin of the python in there and put it in your path before hitting /usr/bin.

For example, on my 10.8, python is located at /usr/local/Cellar/python/2.7.5/bin and I put that directory before /usr/bin/python in my PATH variable.

I do that similarly for other instances of me wanting to use homebrew version of an app, another example being sqlite.

  • 2
    A better answer is to (1) ``brew link python`` (possibly with ``--overwrite`` if there's an older Python or pip under ``/usr/localbin`` - then (2) ensure ``/usr/local/bin`` is at the front of your ``PATH`` - this works for any brew package, not just Python, and avoids editing your path for every such package. – RichVel Sep 23 '13 at 21:03