Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have for some reason two locations for python site packages.

Python itself is here:

> $ which python
> /Library/Frameworks/Python.framework/Versions/2.7/bin/python

My Path Variable is:

$ echo $PATH
/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/opt/opengeo/pgsql/9.1/bin

xlrd is installed here and can be accessed from python

> $ pip install xlrd
> Requirement already satisfied (use --upgrade to upgrade): xlrd in /Library/Python/2.7/site-packages

$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import xlrd
>>> 

numpy is installed here and can not be accessed from python

> $ pip install numpy
> Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python2.7/site-packages

$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy

What do I have to do to get numpy also working with python. I am looking for the 'cleanest solution'.

share|improve this question
1  
Don't you have a Python in /usr/bin/ ? and Did you change your $path variable ? –  Matthieu Riegler Jun 1 '13 at 17:41
    
Thanks for the hints. I edited my original post. –  ustroetz Jun 1 '13 at 17:46
    
@MatthieuRiegler: would it makes sense to delete the $path variable? –  ustroetz Jun 1 '13 at 17:47
    
WHat does which pip give? –  Mark Jun 1 '13 at 17:54
    
@Mark $ which pip /usr/local/bin/pip –  ustroetz Jun 1 '13 at 17:58
show 4 more comments

1 Answer 1

As a short-term solution, you should be able to run

cp /usr/local/lib/python2.7/site-packages/numpy* /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/

as the versions of python are the same, and /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages is (amongst other places) where your python binary will be looking for modules.

I'm concerned that /usr/bin/python doesn't exist, as this is what is shipped with OSX and is required for some system/OS stuff to run. The reason you have so many site-packages directories (you actually have more than you listed in your question) is that it seems like you've installed a python.org version (the /Library/Frameworks/... one) and perhaps a third-party version from Homebrew or some other package manager (MacPorts by default installs into the /opt/local directory). Your version of pip was also installed from that source, so if you want to use the python.org version as your default then you'll need to install pip again (make sure you use the setuptools version, as distribute is defunct). After that's all done, you can then run pip install numpy --upgrade to make sure you've got the latest version, which is 1.7.1 currently.

share|improve this answer
    
I am looking for a clean solution. Is there a way to restore /usr/bin/python –  ustroetz Jun 2 '13 at 0:42
    
@user1738154 do you still have /usr/bin/pythonw? It is identical to the python binary, so a sudo cp /usr/bin/pythonw /usr/bin/python should do the trick. –  MattDMo Jun 3 '13 at 3:22
    
That is strange. After doing what you said I get cp: /usr/bin/python and /usr/bin/pythonw are identical (not copied) –  ustroetz Jun 3 '13 at 3:42
    
@user1738154 so apparently you have /usr/bin/python after all... so much for that problem :) –  MattDMo Jun 3 '13 at 3:46
    
Well there is a Unix Executable File called python. –  ustroetz Jun 3 '13 at 4:15
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.