gpt4 book ai didi

macos - 导入 matplotlib 时 numpy 的版本错误

转载 作者:行者123 更新时间:2023-12-04 12:08:57 24 4
gpt4 key购买 nike

当我

import matplotlib

我没有收到任何错误,但是当我
import matplotlib.pyplot

我得到
RuntimeError: module compiled against API version 8 but this version of numpy is 7
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/matplotlib/pyplot.py", line 24, in <module>
import matplotlib.colorbar
File "/Library/Python/2.7/site-packages/matplotlib/colorbar.py", line 27, in <module>
import matplotlib.artist as martist
File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 8, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, \
File "/Library/Python/2.7/site-packages/matplotlib/transforms.py", line 35, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: numpy.core.multiarray failed to import

这看起来像 version error ;但是 yolk说我有一个最新版本,和 pip说一切都是最新的,不会帮助“真正”更新事物。

我该怎么做才能确保必要的软件包“真正”是最新的,以避免出现此错误;哪些包需要“真正”更新(matplotlib;numpy;其他?)。

卸载和重新安装 numpy(使用 pip)没有帮助。

pip 是否以某种方式让我最近将 matplotlib 更新为“太新”的版本,而 numpy 的 pip 版本滞后?

我的 sys.path是:
['',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']

并且 Scypi 堆栈安装在 site-packages它由 pip 维护。 OS X 10.9,Apple Python 2.7.5,所有包版本都是通过 pip 在 PiPy 中找到的版本。

最佳答案

在这种情况下强制重新安装有效,因为在类似情况下通常会这样做:

sudo pip install -U --force-reinstall scipy

关于macos - 导入 matplotlib 时 numpy 的版本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19618685/

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