导入matplotlib.pyplot作为plt失败

时间:2018-09-22 16:11:31

标签: python matplotlib

File "<stdin>", line 1, in <module>
  File "C:\Users\franc\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 32, in <module>
    import matplotlib.colorbar
  File "C:\Users\franc\Anaconda3\lib\site-packages\matplotlib\colorbar.py", line 32, in <module>
    import matplotlib.contour as contour
  File "C:\Users\franc\Anaconda3\lib\site-packages\matplotlib\contour.py", line 18, in <module>
    import matplotlib.font_manager as font_manager
  File "C:\Users\franc\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 1363, in <module>
    _rebuild()
  File "C:\Users\franc\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 1344, in _rebuild
    fontManager = FontManager()
  File "C:\Users\franc\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 978, in __init__
    ttffiles = findSystemFonts(paths) + findSystemFonts()
  File "C:\Users\franc\Anaconda3\lib\site-packages\matplotlib\font_manager.py", line 264, in findSystemFonts
    fontfiles.update(win32InstalledFonts(fontext=fontext))
TypeError: 'NoneType' object is not iterable

我已尝试通过多种方式卸载并重新安装matplotlib,但仍然收到上述错误。

1 个答案:

答案 0 :(得分:1)

我遇到了这个问题,并通过安装旧版本对其进行了修复。试试:

pip uninstall matplotlib

pip install -v matplotlib==2.2.2

此错误似乎是由于在matplotlib.font_manager.py中错误使用pathlib软件包引起的。