Numpy Install Mac Osx Python
Asked Answered
C

2

7

I am using Python for my Linear Algebra course for programming. For the tools we need, I am trying to install NumPy. I used this website to guide me through the installation process.

I started from the links on SciPy's OS X page and eventually arrived at the SourceForge download site.

From there, I chose the Mac OS X installer numpy-1.6.1-py2.7-python.org-macosx10.3.dmg.

When I went to Idle and typed in

>>> import numpy as np

This is the error I received:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
    import add_newdocs
  File "/Library/Frameworks/Python.framework/Versions/2.7/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/2.7/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module>
    from type_check import *
  File "/Library/Frameworks/Python.framework/Versions/2.7/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/2.7/lib/python2.7/site-packages/numpy/core/__init__.py", line 5, in <module>
    import multiarray
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so: no matching architecture in universal wrapper

I also tried it from the terminal and got the same error. I have a virtual environment installed - virtual env wrapper. I called the environment in the terminal by:

source my_new_env/bin/activate

And then I tried to import numpy in the terminal that way, but then I got the error:

(my_new_env) $ sudo python  -c 'import numpy; numpy.test()'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named numpy

I am not sure if I installed NumPy incorrectly or if my virtual environment is conflicting with Nose. If anyone has suggestions let me know!

Celery answered 9/2, 2013 at 20:39 Comment(1)
Do you have pip installed? If so, all you need to do to install is 'pip install numpy'. If you want to see what you have installed already (what packages and versions), you can then do 'pip freeze'Ravioli
E
2

i would skip the MacOS package install and use the 'pip install' instructions, since you're already familiar with virtualenvs. use these instructions instead: http://www.scipy.org/install.html#installing-via-pip

it's easier to work with a virtualenv and pip, which will ensure post-install that your virtualenv will have access to the modules you've installed. it takes more work to do that with an external package (or .dmg) that you've downloaded. not impossible, just more work. HTH.

Equinoctial answered 12/11, 2016 at 0:51 Comment(1)
Installing via pip worked perfectly for me, on both Python 2.7 and 3.5.Orphaorphan
G
0

Try these commands:

brew update, brew doctor

, because, in my case, I didn't even have to install numpy separately. Yet I could import numpy easily. Meanwhile you can try downloading the numpy package from this website.

Glaydsglaze answered 4/4, 2016 at 9:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.