Spyder plots non responding with the Tkinter backend

雨燕双飞 提交于 2020-05-09 10:51:44

问题


plotting under spyder 4 (and also after downgrading with 3) doesn't work. I am just doing:

data=[1,2,3]
plt.plot(data)

The output is a non-responding frame: After forcing to close it, i get:

An error ocurred while starting the kernel
RROR:tornado.application:Exception in callback functools.partial(.advance_eventloop at 0x000001A802791318>)
Traceback (most recent call last):
File "path\anaconda3\lib\site‑packages\tornado\ioloop.py", line 743, in _run_callback
ret = callback()
File "path\anaconda3\lib\site‑packages\ipykernel\kernelbase.py", line 310, in advance_eventloop
eventloop(self)
File "path\anaconda3\lib\site‑packages\ipykernel\eventloops.py", line 232, in loop_tk
app.tk.createfilehandler(stream.getsockopt(zmq.FD), READABLE, notifier)
AttributeError: '_tkinter.tkapp' object has no attribute 'createfilehandler'

(where is replaced with path) Any idea why?

(if relevant i am using windows, python3)

Edit

adding plt.show() alone doesn't make a difference to the output (still blank frame), but thanks to Neven V. and other quests i added

root = tk.Tk()

def on_closing():
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        root.destroy()

root.protocol("WM_DELETE_WINDOW", on_closing)
root.mainloop()

then i see a plot where the frame is responding. But after clicking on quit, the process do not quit and i have to restart the kernel (the mainloop is halting it but without it i get the result: no plot), thus i tried:

plt.show(block=False)
plt.pause(0.001) # Pause for interval seconds.
input("hit[enter] to end.")
plt.close('all') # all open plots are correctly closed after each run

and see a plot but it is non responding also after hitting enter.

来源:https://stackoverflow.com/questions/60897047/spyder-plots-non-responding-with-the-tkinter-backend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!