gpt4 book ai didi

python - import matplotlib.pyplot 给出 ImportError : dlopen(…) Library not loaded libpng15. 15.dylib

转载 作者:IT老高 更新时间:2023-10-28 20:34:10 25 4
gpt4 key购买 nike

I am aware that this exact same question has been asked before.我确实按照那里的答案中给出的说明进行操作,但它并没有解决我的问题(而且我没有足够的声誉来评论该线程中的 Q 或 A)。无论如何,这就是发生的事情:

我尝试做:

import matplotlib.pyplot

作为返回,我得到:

Traceback (most recent call last):
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 3032, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-eff513f636fd>", line 1, in <module>
import matplotlib.pyplot as plt
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 56, in <module>
import matplotlib.textpath as textpath
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/mathtext.py", line 63, in <module>
import matplotlib._png as _png
ImportError: dlopen(/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/_png.so, 2): Library not loaded: libpng15.15.dylib
Referenced from: /Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/_png.so
Reason: image not found

我的 Python 版本:

2.7.7 |Anaconda 2.0.1 (x86_64)| (default, Jun  2 2014, 12:48:16) [GCC 4.0.1 (Apple Inc. build 5493)]

编辑:

cel 的建议奏效了!我刚刚尝试了“conda remove matplotlib”、“pip install matplotlib”,然后是“conda install matplotlib”,然后!伙计,你不知道这个问题困扰了我多久。祝福大家。

最佳答案

一些 python 包动态链接到本地​​ c 库。更新其中一个库后,链接可能会中断,并为您提供有关缺少动态库的奇怪错误消息,如问题中的错误消息所示。

基本上,在更新原生库后,有时您还必须重新构建 python 包(此处为 matplotlib)。

上述陈述一般是正确的。如果您使用 conda因为你的 python 发行版通常不那么复杂:

对于扩展包conda还维护所需的 c 库。只要你只用conda installconda update对于安装这些软件包,您不应该遇到这些问题。

对于 numpy , scipy , matplotlib还有更多我建议尝试conda search <library name>先看看有没有conda符合您需求的食谱。对于大多数用户conda install <library name>将是比 pip install 更好的选择.

确保只有 conda的版本安装好了就可以了

conda remove matplotlib
pip uninstall matplotlib
conda install matplotlib

之后这个问题应该不会再出现了。

关于python - import matplotlib.pyplot 给出 ImportError : dlopen(…) Library not loaded libpng15. 15.dylib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28848270/

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