当我尝试以下操作时(在Python3中):
>>> import matplotlib.pyplot as pl
>>> pl.plot([1, 2, 3])
>>> pl.show()
最后我得到一个错误:
^{pr2}$但当我执行以下操作时,它会起作用:
>>> from matplotlib.font_manager import FontManager
>>> FontManager().ttf_lookup_cache
{}
但是FontManager
构造函数需要一些时间(~1.5s),而第一个代码则没有。在
另外,上面的代码在python2中运行得非常好,我发现一些帖子提出了类似的问题,比如:
……但这些答案对我都不管用。在
如果有帮助的话,我正在用python3.4.3和matplotlib
1.3.1开发ubuntu14.04.4。在
经过大量的挖掘,我意识到问题可能是我使用的
matplotlib
的旧版本(使用apt-get install
安装)。我尝试删除它并使用pip
安装它,它成功了:之后,我第一次导入
matplotlib.pyplot
(关于构建字体缓存)时收到了一条警告。现在一切正常。在使用
pip3
安装的matplotlib
版本是1.5.1(来自使用apt
的1.3.1)。在相关问题 更多 >
编程相关推荐