import numpy as np
import matplotlib.pyplot as plt
提供错误
Traceback (most recent call last):
File "/home/xx/PycharmProjects/Udemy/Array_Processing.py", line 2, in <module>
import matplotlib.pyplot as plt
File "/home/xx/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/home/xx/anaconda/lib/python2.7/site-packages/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/home/xx/anaconda/lib/python2.7/site-packages/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/home/xx/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 56, in <module>
import matplotlib.textpath as textpath
File "/home/xx/anaconda/lib/python2.7/site-packages/matplotlib/textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "/home/xx/anaconda/lib/python2.7/site-packages/matplotlib/mathtext.py", line 63, in <module>
import matplotlib._png as _png
ImportError: libpng15.so.15: cannot open shared object file: No such file or directory
有什么办法可以解决这个问题吗?我猜是软件包安装不正确。我主要使用 Windows 进行 Python 编码,但是,不知道这里该怎么做。
答案1
如果尚未安装,请尝试matplotlib
通过conda
命令进行安装。anaconda 的库与 pip 等为 python 安装的库是分开的。我猜 anaconda 实际上找不到该库。另一种可能是它使用了不兼容的库,在这种情况下,请卸载 matplotlib,然后使用conda
install。
答案2
看来,由于我正在运行anaconda
,因此依赖项和包需要在虚拟环境中自行安装。
因此,conda install matplotlib
是解决方案。