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




解决方法:

打开:font_manager.py
路径自己看下(可能不同):
C:/Users/IBM/Anaconda3/lib/site-packages/matplotlib/font_manager.py。
2
在231行,(前后几行找找)
把:direc = os.path.abspath(direc).lower()
改为:direc = direc.split('\0', 1)[0]
保存,运行。ok啦

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值