gpt4 book ai didi

python - numpy.core.multiarray 导入失败

转载 作者:太空狗 更新时间:2023-10-29 17:47:10 25 4
gpt4 key购买 nike

我使用以下命令来了解我正在使用的 numpy 版本

pip show numpy

输出如下所示

---
Name: numpy
Version: 1.8.2
Location: /usr/lib/python2.7/dist-packages
Requires:

然而,当我运行 matplotlib 时,出现错误

RuntimeError: module compiled against API version a but this version of numpy is 9
from matplotlib import pyplot as plt
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/usr/local/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "/usr/local/lib/python2.7/dist-packages/matplotlib/artist.py", line 12, in <module>
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
File "/usr/local/lib/python2.7/dist-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,

我尝试升级 numpy,

pip install numpy --upgrade

显示安装成功,但是numpy还是显示为1.8.2,运行matplotlib时仍然报错。

我想卸载numpy并重新安装它,系统给出消息说

Not uninstalling numpy at /usr/lib/python2.7/dist-packages, owned by OS

如何解决?关于

的任何想法

RuntimeError: module compiled against API version a but this version of numpy is 9

最佳答案

How can I upgrade numpy?可能对你有用。在那种情况下,这是一个路径问题:

RuntimeError: module compiled against API version 9 but this version of numpy is 6
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import

解决方法:

检查路径

import numpy
print numpy.__path__

然后使用rm手动删除它

关于python - numpy.core.multiarray 导入失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34051737/

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