简体   繁体   English

导入 matplotlib.pyplot 作为 plt 失败

[英]import matplotlib.pyplot as plt failed

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

I've tried to uninstall and reinstall matplotlib in many ways, but I still get the above error.我尝试通过多种方式卸载并重新安装matplotlib ,但仍然出现上述错误。

I met this problem and fixxed it with installing the old version.我遇到了这个问题并通过安装旧版本修复了它。 Try:尝试:

pip uninstall matplotlib

pip install -v matplotlib==2.2.2

It seem that this bug casued by the incorrect use of pathlib package in matplotlib.font_manager.py似乎这个错误是由在 matplotlib.font_manager.py 中不正确使用 pathlib 包引起的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM