Joseph James Farrugia Joseph James Farrugia - 1 year ago 115
Python Question

NumPy: Import Error, Image Not Found OSX

Basically just started getting into Python and making the gradual switchover from Matlab.

I'm having trouble importing packages for use in my Python scripts.

I downloaded Anaconda (which, to my knowledge, installs Python) and proceeded to download "NumPy" through the command line in terminal.

I am using IDLE currently as my Python text editor, and all is well, if I save my .py file and run it through Terminal as, for example, python It finds the NumPy library and executes fine:

#!/usr/bin/env python
import numpy as np


[[ 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0.]]

However, trying to import numpy through terminal after activating the Python shell via Python3.5, the following happens.

>>> import numpy as np
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/", line 184, in <module>
from . import add_newdocs
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/", line 13, in <module>
from numpy.lib import add_newdoc
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/lib/", line 8, in <module>
from .type_check import *
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/lib/", line 11, in <module>
import numpy.core.numeric as _nx
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/", line 14, in <module>
from . import multiarray
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/, 10): Library not loaded: @loader_path/../../../../libmkl_intel_lp64.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/
Reason: image not found

The same message comes up if I try to run the script through the Python shell in IDLE. I'm thinking it's looking for the library NumPy in the wrong place, but I'm not sure how to correct the issue.

Answer Source

Run the graphical installer for your operating system and version and make sure you select to install on "Macintosh HD". The installation you ran likely installed in your local Library folder (/Users/yourusername/Library), but the location being checked is the global library folder, /Library/.