首页 > 其他 > 详细

mlbox ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running

时间:2021-05-01 09:10:14      阅读:174      评论:0      收藏:0      [点我收藏+]

真是巨大的坑,按照网上说的,matplotlib.use(‘agg‘),修改matplotlibrc文件中的backend,plt.switch_backend(‘Agg‘),%matplotlib inline统统失效,包括在启动Jupyter时设置环境变量export MPLBACKEND=Agg,在运行Reader(sep=‘,‘).train_test_spilt(paths, target_name)时,依然会报错。
之后看了一下报错的堆栈,在执行这一句时,应该是启动了新的进程,所以,在jupyter中无论怎么设置maplotlib,在新启动的进程中,这个设置无法生效,万般无奈下,按照报错的其中一个文件python3.8/site-packages/mlbox/prediction/predictor.py,打开一看,瞬间气晕了,15行开始写了如下的语句

try:
    matplotlib.use(‘TkAgg‘)
except:
    pass

所以,这就难怪会报标题那样的错了,把这句话注掉,或者改成matplotlib.use(‘agg‘),重启kernel,一切完美!

mlbox ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running

原文:https://www.cnblogs.com/stevenluo/p/14723704.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!