使用subplots出现Canceled future for execute_request message before replies were done
关于jupyter notebook中使用subplots时报错Canceled future for execute_request message before replies were done(已解决)
·
Canceled future for execute_request message before replies were done
The Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click here for more info. View Jupyter log for further details.
如上报错
运行FashionMNIST数据集的打印图像函数时出错
def show_fashion_mnist(images,labels):
display.set_matplotlib_formats('svg')
_,figs = plt.subplots(1, len(images), figsize=(12, 12))
for f, img, lbl in zip(figs, images, labels):
f.imshow(img.view((28, 28)).numpy())
f.set_title(lbl)
f.axes.get_xaxis().set_visible(False)
f.axes.get_yaxis().set_visible(False)
plt.show()
排查时发现单独运行一行plt.subplots会报错
经过反复尝试,确认了一点就是,想要使用正常,可以先运行matplotlib
如下
之后再运行在别的地方时这个subplots都会正常,原理我也没搞明白,但是能用就行
差不多就是下面这个意思,把它优先级搞上去,先运行matplotlib和subplots
最近发现第二种办法,加上如下一段代码就可以解决了
import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
更多推荐
已为社区贡献1条内容
所有评论(0)