anaconda3:matplotlib 失败。

anaconda的matplotlib运行失败。
当输入:import matplotlib.pyplot as plt时,显示:
runfile('C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib/font_manager.py', wdir='C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib')
Traceback (most recent call last):
File "<ipython-input-17-7aac24dabdcd>", line 1, in <module>
runfile('C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib/font_manager.py', wdir='C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib')
File "C:\Users\IBM\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile
execfile(filename, namespace)
File "C:\Users\IBM\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 88, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib/font_manager.py", line 1421, in <module>
_rebuild()
File "C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib/font_manager.py", line 1406, in _rebuild
fontManager = FontManager()
File "C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib/font_manager.py", line 1044, in __init__
self.ttffiles = findSystemFonts(paths) + findSystemFonts()
File "C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib/font_manager.py", line 313, in findSystemFonts
for f in win32InstalledFonts(fontdir):
File "C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib/font_manager.py", line 231, in win32InstalledFonts
direc = os.path.abspath(direc).lower()
File "C:\Users\IBM\Anaconda3\lib\ntpath.py", line 535, in abspath
path = _getfullpathname(path)
ValueError: _getfullpathname: embedded null character

操作方法

  • 01

    打开:font_manager.py 路径自己看下(可能不同): C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib/font_manager.py。

  • 02

    在231行,(前后几行找找) 把:direc = os.path.abspath(direc).lower() 改为:direc = direc.split('\0', 1)[0] 保存,运行。ok啦

(0)

相关推荐