1

Update the problem:

I use

sudo python3
>>import numpy

It works!

And I use the suggestion of below comments :

delete the /usr/local/lib/python2.7/site-packages in path.

and the problem solved!

======== the old problem ===========

I'm using Mac OS El Capitan.

The Python2.7 is the default version; python3.5 is installed from the official site python3.5 for mac.

I have already installed numpy in python2.7. Now I need to install numpy in python3.5.

I use:

pip3 install numpy

which return

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

and when I run

python3
>>import numpy

in python3

it outputs:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 170, in <module>
    from . import add_newdocs
  File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 6, in <module>
    from . import multiarray
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type
  Referenced from: /usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so
  Expected in: flat namespace
 in /usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so

It link the 2.7 package.. and show error.

(Similar Problem happens when I install scipy and sklearn)

How to solve the problem?

Cœur
  • 37,241
  • 25
  • 195
  • 267
bengxy
  • 119
  • 1
  • 6
  • 2
    Check your PYTHONPATH. I guess when you installed numpy for Python 2.7, you set your PYTHONPATH to include `/usr/local/lib/python2.7/site-packages`. –  Mar 11 '16 at 11:00
  • I use `sudo python3` and the problem is solved. But I don't know why this happened... – bengxy Mar 11 '16 at 11:11
  • Thank you, It solved when I delete this line. I added this line long long ago when I installed opencv... Thank you very much. – bengxy Mar 11 '16 at 11:24

2 Answers2

1

I ran into the same problem. Uninstalling numpy using pip3, and reinstalling, fixed the issue.

pip3 uninstall numpy pip3 install numpy

Keven Wang
  • 1,208
  • 17
  • 28
-3

An easy way to avoid this is to install all these modules using anaconda. https://www.continuum.io/downloads It will avoid you the headache of installing manually.

Stijn Van Daele
  • 285
  • 1
  • 14
  • 2
    If the OP installs numpy with `pip3` and uses `python3`, this shouldn't be necessary. –  Mar 11 '16 at 10:59