Reputation: 400
I install matplotlib but python 3.8.10 show me this error.
AttributeError: module 'matplotlib' has no attribute 'font_manager'
import sys
sys.path.append(r'C:\Python38\Lib\site-packages')
sys.path.append(r'C:\Python38\Lib\site-packages\matplotlib')
import matplotlib
system_fonts = matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')
print(dir(system_fonts))
Upvotes: 3
Views: 10378
Reputation: 33345
font_manager
is a sub-module, and sub-modules aren't imported automatically. Sometimes the __init__.py
module will import a sub-module for you, but you can't always count on this.
Import it explicitly:
import matplotlib.font_manager
Upvotes: 4