Error in GoogleColab (Python)- TclError: no display name and no $DISPLAY environment variable
Error in GoogleColab (Python)- TclError: no display name and no $DISPLAY environment variable
有人知道如何修复 GoogleColab Notebook 中 Python 中的以下错误吗?我是 运行 下面的代码:-
import matplotlib.pyplot as plt
from matplotlib import style
style.use('fivethirtyeight')
import tkinter as tk
from tkinter import filedialog
from tkinter import *
from PIL import ImageTk, Image
import numpy
import keras
from keras.models import load_model
from sklearn.metrics import accuracy_score
model = load_model('training_model.h5')
classes = { 1: 'Speed Limit 20 km/h',
2: 'Speed Limit 30 km/h',
3: 'Speed Limit 50 km/h' }
#initialize GUI
top = tk.Tk()
top.geometry('800x600')
top.title('Traffic Sign Recognition Project Report')
top.configure(background='#EEE')
label=Label(top,background='#CDCDCD', font=('arial',15,'bold'))
sign_image = Label(top)
我在 -> top = tk.Tk()
行收到错误
由于很多原因,无法在 Google Colaboratory
上使用 tkinter
。首先,即使您按照 here 设法让它工作,正如它提到的那样:
However, if you want to interact with the GUI, that's going to be hard, 'cuz Colab doesn't support interactive screens out of the box.
也来自那里的其他答案:
Servers generally don't even have a display. And even if they had, you wouldn't see it. You will have to run Python on your desktop or laptop to use tkinter.
我无法将此问题作为重复问题关闭,因为另一个问题没有选择正确答案。
有人知道如何修复 GoogleColab Notebook 中 Python 中的以下错误吗?我是 运行 下面的代码:-
import matplotlib.pyplot as plt
from matplotlib import style
style.use('fivethirtyeight')
import tkinter as tk
from tkinter import filedialog
from tkinter import *
from PIL import ImageTk, Image
import numpy
import keras
from keras.models import load_model
from sklearn.metrics import accuracy_score
model = load_model('training_model.h5')
classes = { 1: 'Speed Limit 20 km/h',
2: 'Speed Limit 30 km/h',
3: 'Speed Limit 50 km/h' }
#initialize GUI
top = tk.Tk()
top.geometry('800x600')
top.title('Traffic Sign Recognition Project Report')
top.configure(background='#EEE')
label=Label(top,background='#CDCDCD', font=('arial',15,'bold'))
sign_image = Label(top)
我在 -> top = tk.Tk()
由于很多原因,无法在 Google Colaboratory
上使用 tkinter
。首先,即使您按照 here 设法让它工作,正如它提到的那样:
However, if you want to interact with the GUI, that's going to be hard, 'cuz Colab doesn't support interactive screens out of the box.
也来自那里的其他答案:
Servers generally don't even have a display. And even if they had, you wouldn't see it. You will have to run Python on your desktop or laptop to use tkinter.
我无法将此问题作为重复问题关闭,因为另一个问题没有选择正确答案。