简体   繁体   English

numpy / core / multiarray.so:未定义符号:_Py_ZeroStruct

[英]numpy/core/multiarray.so: undefined symbol: _Py_ZeroStruct

I'm new to both Linux and Python. 我是Linux和Python的新手。 I'm working on a Ubuntu 16.04. 我正在使用Ubuntu 16.04。

My original Python is 我原来的Python是

python --version Python 2.7.8

I'm trying to import numpy into python3. 我正在尝试将numpy导入python3。 However, when I try to import numpy I get this error 但是,当我尝试导入numpy时,出现此错误

Traceback (most recent call last): Traceback(最近一次调用最后一次):

File "/usr/local/lib/python2.7/dist-packages/numpy/core/ init .py", line 16, in from . 从中输入文件“ /usr/local/lib/python2.7/dist-packages/numpy/core/ init .py”,第16行。 import multiarray ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: _Py_ZeroStruct 导入多数组ImportError:/usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so:未定义的符号:_Py_ZeroStruct

During handling of the above exception, another exception occurred: 在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/numpy/ init .py", line 142, in from . 追溯(最近一次通话最近):文件“ /usr/local/lib/python2.7/dist-packages/numpy/ init .py”的第1行,第142行,来自。 import add_newdocs File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in from numpy.lib import add_newdoc File "/usr/local/lib/python2.7/dist-packages/numpy/lib/ init .py", line 8, in from .type_check import * File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in import numpy.core.numeric as _nx File "/usr/local/lib/python2.7/dist-packages/numpy/core/ init .py", line 26, in raise ImportError(msg) 在numpy.lib中,从第13行导入add_newdocs文件“ /usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py” import add_newdoc文件“ /usr/local/lib/python2.7/dist -packages / numpy / lib / init .py“,第8行,来自.type_check import *文件“ /usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py”,第11行在导入numpy.core.numeric中作为_nx文件“ /usr/local/lib/python2.7/dist-packages/numpy/core/ init .py”,第26行,在抬高ImportError(msg)

ImportError: Importing the multiarray numpy extension module failed. ImportError:导入多数组numpy扩展模块失败。

Most likely you are trying to import a failed build of numpy. 您极有可能尝试导入失败的numpy构建。 If you're working with a numpy git repo, try git clean -xdf (removes all files not under version control). 如果您使用的是numpy git repo,请尝试使用git clean -xdf(删除所有不受版本控制的文件)。 Otherwise reinstall numpy. 否则,请重新安装numpy。

Original error was: 原始错误是:

/usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: _Py_ZeroStruct" /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so:未定义符号:_Py_ZeroStruct“

The python I'm using to import numpy is Python 3.5.2 and it seems to be trying to use the package in Python 2.7. 我用来导入numpy的python是Python 3.5.2,它似乎正在尝试使用python 2.7中的软件包。

I've tried : 我试过了 :

sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-numpy

and also : 并且 :

sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall 
sudo apt install python3-numpy python3-scipy

It seems a similar problem to what others have faced but none of the solutions seem to work? 似乎与其他人所面临的问题类似,但似乎没有一个解决方案可行?

You installed pip for both python2.7 and python3. 您为python2.7和python3安装了pip。 To use pip of python3 just you need to use pip3 instead of pip. 要使用python3的pip,只需使用pip3而不是pip。

pip3 install package

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM