1
當我嘗試以下方法(在Python 3):ttf_lookup_cache屬性不FontManager發現
>>> import matplotlib.pyplot as pl
>>> pl.plot([1, 2, 3])
>>> pl.show()
我得到一個錯誤,並在最後:
AttributeError: 'FontManager' object has no attribute 'ttf_lookup_cache'
但是,當我下面的工作原理:
>>> from matplotlib.font_manager import FontManager
>>> FontManager().ttf_lookup_cache
{}
但FontManager
構造需要一定的時間(1.5秒〜),而第一個代碼不。
而且,上面的代碼工作與Python 2完全沒有問題,我發現了一些帖子,詢問類似的問題,如:
- Plotting with Matplotlib in Python 3 pylab: Tkinter and Qt FontManager errors
- Matplotlib font_manager.py font finding error
...但沒有的答案爲我工作。
如果有幫助,我正在使用python 3.4.3和matplotlib
1.3.1的Ubuntu 14.04.4。