Tkinter使Jupyter内核崩溃? [英] Tkinter crashes Jupyter kernel?

查看:278
本文介绍了Tkinter使Jupyter内核崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我是第一次开始使用tkinter(8.6.7),通过conda将其安装到其中一个带有python 3.5.4的环境中,并且由于某些原因,它一直使我的jupyter笔记本电脑崩溃.这是我使用的简单代码,

So I'm starting out with tkinter (8.6.7) for the first time, installed via conda unto one of my environments with python 3.5.4 on it, and for some reasons it just keeps crashing my jupyter notebook. This is the simple code I use,

from tkinter import filedialog
from tkinter import *

root = Tk()
root.filename =  filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("jpeg files","*.jpg"),("all files","*.*")))

,一旦我退出使用Finder打开的对话框窗口(我在Mac上),即使我没有选择任何文件并按Cancel,我的内核也会崩溃并重新启动.

and as soon as I exit the dialog window that gets opened using Finder (I'm on a mac), my kernel crashes and restarts, even if I pick no files and just press cancel.

有人知道为什么这种情况持续发生吗?我的环境是最新的,可以使用numpy,例如,没有问题.

Does anyone have any idea why this keeps happening? My environment is up to date, and can use numpy, for ex., with no problems.

推荐答案

我复制了您的问题.使用%% python魔术可以解决我的问题.试试这个:

I replicated your problem. Using the %%python magic solved if for me. Try this:

%%python

from tkinter import filedialog
from tkinter import *

root = Tk()
root.filename =  filedialog.askopenfilename(initialdir = "/",title = "Select 
file",filetypes = (("jpeg files","*.jpg"),("all files","*.*"))

这篇关于Tkinter使Jupyter内核崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆