TclError:谷歌的colab中没有显示名称并且没有$ DISPLAY环境变量 [英] TclError: no display name and no $DISPLAY environment variable in google's colab

查看:300
本文介绍了TclError:谷歌的colab中没有显示名称并且没有$ DISPLAY环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此错误:

TclError: no display name and no $DISPLAY environment variable

当我尝试在Google的新colab工具(协作式Jupyter笔记本)中运行Python 3.6程序时出现.我正在Windows 10计算机上的Chrome中运行colab.我已经在堆栈溢出的其他线程中看到了此错误,但是在colab的环境中却没有看到此错误,并且以前发布的解决方案要么不适用,要么似乎不起作用.我的代码是这样开始的:

arose when I tried to run a Python 3.6 program inside google's new colab facility (collaborative Jupyter notebooks). I am running colab in Chrome on a Windows 10 machine. I've seen this error reported in other threads on stackoverflow but not in the context of colab, and previously posted solutions either don't apply or don't seem to work. My code begins like this:

from matplotlib.pyplot import *
from matplotlib.widgets import *
from math import *
from random import *
from numpy import *
from tkinter import *

请注意,要使tkinter导入正常工作,我必须在其他Colab单元中发出以下指令:

Note that to get the import of tkinter to work, I had to issue the following instruction in a different Colab cell:

!apt-get install python3-tk

推荐答案

问题是您要使用的tkinter.

Tk通常会为您的界面创建GUI(如新窗口).但是Colab是在云中的Web服务器上运行的.它无法在您的计算机上打开一个窗口.您只能通过笔记本界面与之交互.

Tk will normally create GUI (like a new window) for your interface. But Colab is run on the web server in the cloud. It can't open a window on your machine. You can only interact with it through notebook interface.

您需要限制交互作用以不使用GUI.或通过笔记本将其更改为基于Web的.您要运行哪种程序?

You need to limit the interaction not to use GUI. Or change them to web-based through notebook. What kind of program are you trying to run?

这篇关于TclError:谷歌的colab中没有显示名称并且没有$ DISPLAY环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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