Dmitry Dronov
Dmitry Dronov

Reputation: 400

AttributeError: module 'matplotlib' has no attribute 'font_manager'

I install matplotlib but python 3.8.10 show me this error.

AttributeError: module 'matplotlib' has no attribute 'font_manager'

What i am doing wrong? enter image description here

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

Answers (1)

John Gordon
John Gordon

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

Related Questions