import matplotlib.pyplot gives ImportError: dlopen(…) Library not loaded libpng15.15.dylib
import matplotlib.pyplot gives ImportError: dlopen(…) Library not loaded libpng15.15.dylib
I am aware that this exact same question has been asked before. 我确实按照那里的答案中给出的说明进行操作,但它并没有解决我的问题(而且我没有足够的声誉来评论该线程中的 Q 或 A) .无论如何,这是正在发生的事情:
我尝试做:
import matplotlib.pyplot
在 return 中我得到:
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 包link 动态针对本地c 库。更新其中一个库后,links 可能会中断并向您提供有关缺少动态库的奇怪错误消息,如问题中的错误消息所示。
基本上,在更新本机库之后,有时您还必须重建 python 包(此处 matplotlib
)。
以上说法大体上是正确的。如果你使用 conda
作为你的 python 分配,事情通常不那么复杂:
对于扩展包 conda
还维护所需的 c 库。只要你只使用 conda install
和 conda 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
以后应该不会再出现这个问题了
我有这个问题,但那是因为我设置了
导出 DYLD_LIBRARY_PATH="/Users/charlesmartin14/anaconda/lib":$DYLD_LIBRARY_PATH
删除此设置并重新启动 shell 修复了它
我运行也遇到了这个问题。我更新了我的 Anaconda-Navigator,下次我用 matplotlib.pyplot
打开一个项目时,我 运行 遇到了类似的问题。对我有用的是:
conda install libpng
I am aware that this exact same question has been asked before. 我确实按照那里的答案中给出的说明进行操作,但它并没有解决我的问题(而且我没有足够的声誉来评论该线程中的 Q 或 A) .无论如何,这是正在发生的事情:
我尝试做:
import matplotlib.pyplot
在 return 中我得到:
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 包link 动态针对本地c 库。更新其中一个库后,links 可能会中断并向您提供有关缺少动态库的奇怪错误消息,如问题中的错误消息所示。
基本上,在更新本机库之后,有时您还必须重建 python 包(此处 matplotlib
)。
以上说法大体上是正确的。如果你使用 conda
作为你的 python 分配,事情通常不那么复杂:
对于扩展包 conda
还维护所需的 c 库。只要你只使用 conda install
和 conda 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
以后应该不会再出现这个问题了
我有这个问题,但那是因为我设置了
导出 DYLD_LIBRARY_PATH="/Users/charlesmartin14/anaconda/lib":$DYLD_LIBRARY_PATH
删除此设置并重新启动 shell 修复了它
我运行也遇到了这个问题。我更新了我的 Anaconda-Navigator,下次我用 matplotlib.pyplot
打开一个项目时,我 运行 遇到了类似的问题。对我有用的是:
conda install libpng