python - Tkinter 导致 Jupyter 内核崩溃?

标签 python tkinter crash jupyter-notebook jupyter

所以我第一次开始使用 tkinter (8.6.7),通过 conda 安装到我的一个带有 python 3.5.4 的环境中,由于某些原因,它一直导致我的 jupyter 笔记本崩溃。这是我使用的简单代码,

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 上),我的内核就会崩溃并重新启动,即使我没有选择任何文件并只按取消键。

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

最佳答案

我复制了你的问题。使用 %%python 魔法解决了我的问题。试试这个:

%%python

from tkinter import filedialog
from tkinter import *

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

关于python - Tkinter 导致 Jupyter 内核崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48130916/

相关文章:

python - 无法将图像加载到 pygame 显示

python-3.x - 如何根据 tkinter 列表框中已打乱项目的索引设置选择栏

python-2.7 - python tkinter 中 config() 的实用程序

c++ - 在 C++ 服务和用户模式应用程序崩溃后收集崩溃的 .dmp 和 .hdmp 文件

Python Pandas Dataframe - 优化在另一个 Dataframe 中搜索 id

python - 如何避免 "RuntimeError: dictionary changed size during iteration"错误?

python - 根据重复行创建数据框

python - Tkinter turtle 和线程

android - Play 管理中心崩溃集群显示新的应用崩溃报告

iphone - 调用 initWithNibName 后在 iPhone 4.3 模拟器上运行时应用程序崩溃