gpt4 book ai didi

python - numpy/核心/multiarray.so : undefined symbol: _Py_ZeroStruct

转载 作者:太空宇宙 更新时间:2023-11-04 11:54:00 27 4
gpt4 key购买 nike

我是 Linux 和 Python 的新手。我正在使用 Ubuntu 16.04。

我原来的Python是

python --version
Python 2.7.8

我正在尝试将 numpy 导入 python3。但是,当我尝试导入 numpy 时出现此错误

Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/numpy/core/init.py", line 16, in from . import multiarray ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: _Py_ZeroStruct

在处理上述异常的过程中,又发生了一个异常:

Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/numpy/init.py", line 142, in from . 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)

ImportError:导入多数组 numpy 扩展模块失败。

Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try git clean -xdf (removes all files not under version control). Otherwise reinstall numpy.

原来的错误是:

/usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: _Py_ZeroStruct"

我用来导入 numpy 的 python 是 Python 3.5.2,它似乎试图在 Python 2.7 中使用该包。

我试过了:

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

还有:

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

这似乎与其他人面临的问题类似,但似乎没有一个解决方案有效?

最佳答案

您为 python2.7 和 python3 安装了 pip。要使用 python3 的 pip,您只需要使用 pip3 而不是 pip。

pip3 install package

关于python - numpy/核心/multiarray.so : undefined symbol: _Py_ZeroStruct,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55061870/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com