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?
I ran into the same problem. Uninstalling numpy using pip3, and reinstalling, fixed the issue.
pip3 uninstall numpy pip3 install numpy
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.