I am having trouble with the module on python. Here is my path variable,

/opt/local/bin /opt/local/sbin /Developer/usr/bin /usr/local/git/bin /usr/X11/bin /Users/oskarniburski/.rvm/bin /usr/X11R6/bin /Library/Frameworks/Python.framework/Versions/3.3/bin /Library/Frameworks/Python.framework/Versions/2.7/bin /Library/Frameworks/Python.framework/Versions/Current/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/local/git/bin /usr/X11/bin /Users/oskarniburski/.rvm/bin

and as seen, it goes through 3.3 and 2.7 therefore should it not find the numpy module in python? I cannot do the euler intergration without the numpy module, so I am curious as to what is the solution. I tried reinstall numpy with pip install numpy , but it did not solve my problem (as numpy module is already in python2.7 framework.) Therefore I am not sure why it is unable to locate numpy module. Any help?

The error I get originally was

ImportError: No module named numpy 

Now, after some changes, I get the error:

$ python eulerintegration.py

Traceback (most recent call last):
  File "eulerintegration.py", line 1, in <module>
    import numpy as np
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
    import add_newdocs
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
    from numpy.lib import add_newdoc
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module>
    from type_check import *
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in <module>
    import numpy.core.numeric as _nx
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/__init__.py", line 5, in <module>
    import multiarray
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/multiarray.so: mach-o, but wrong architecture

You need path to numpy in PYTHONPATH environment variable, not in PATH. Also, look at site module documentation to find out, where python normally searches for its modules and at distutils page to find out about normal installation of extension modules and their location.

Location of numpy depends on your Linux distributive: for instance, in Debian 7 I have numpy installed in /usr/lib/pyshared/python2.6/numpy/..., but you might have it installed e.g. in either /usr/local/lib/python2.7/site-packages or /usr/lib/python2.7/site-packages. As for the difference between site-packages and dist-packages see this. /usr/local/.. is used for programs, manually installed by system administrator, including those installed with pip, while /usr/.. is used for programs installed via your distribution's package manager, e.g. apt for Debian or yum for Red Hat.

  • Hey @Bob, how can I access my python path environment variable?. ie: in what file (like bash_profile) can I find it to change it. – Rakso Zrobin Oct 1 '13 at 1:23
  • @RaksoZrobin You can set it in ~/.profile or ~/.bashrc like export PYTHONPATH=/usr/local/lib/python2.7/site-packages, but read man bash to note the difference between interactive and non-interactive and login and non-login shells and their config files. – Boris Burkov Oct 1 '13 at 1:32
  • Tried changing the .bashrc file, but still not luck. this is my bash right now. I am clearly confused. Thanks for the help so far though.: [[ $- != i ]] && return # return if not interactive fish PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting export PYTHONPATH=/usr/local/lib/python2.7/site-packages – Rakso Zrobin Oct 1 '13 at 1:39
  • @RaksoZrobin ok, could you type export PYTHONPATH=/usr/local/lib/python2.7/site-packages in your terminal and then check, whether it helps python to import numpy just for now? I'm still not sure, that your numpy is there, it might be in other locations I suggested. And once again, you don't need $PATH, you need $PYTHONPATH. :) Also, I didn't understand the meaning of "[[ $- != i ]] && return # return if not interactive fish PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting export PYTHONPATH=/usr/local/lib/python2.7/site-packages". Is it excerpt from your config file? – Boris Burkov Oct 1 '13 at 1:44
  • 2
    @RaksoZrobin you need to add the export PYTHONPATH=/usr/local/lib/python2.7/site-packages to your or _/.profile files. Basically, whenever anyone suggests doing something to ~/.bashrc you should do it to ~/.bash_profile. That's because OSX's terminal starts login shells by default. Linux (at least all the ones I've seen) start interactive, non-login shells by default. Login shell's don't read .bashrc, see my answer here for a brief explanation of the differences. – terdon Oct 1 '13 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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