简体   繁体   English

如何在连接到 EC2 实例的 VNC 中运行 python/Tkinter

[英]How to run python/Tkinter in a VNC conected to a EC2 instance

I was able to connect to the EC2 instance through TigerVNC, but when running python applications that have Tkinter I get the following error:我能够通过 TigerVNC 连接到 EC2 实例,但是在运行具有 Tkinter 的 python 应用程序时,我收到以下错误:

Tkinter: no display name and no $DISPLAY environment

Then I ran the following command:然后我运行以下命令:

export DISPLAY=:1

I chose DISPLAY=:1 because when I connect on TigerVNC I put:我选择 DISPLAY=:1 因为当我在 TigerVNC 上连接时,我输入:

ip_address:1

So I get the following error when running python code:所以在运行 python 代码时出现以下错误:

Couldn't connect to display ":1"

Any suggestion to solve this?有什么建议可以解决这个问题吗?

I created a new EC2 instance and when installing lxde I chose gdm3 as the default display manager option.. so I was able to run xcalc with DISPLAY=:1.0.. But when running the application that contained Tkinter I had the same problem.. The solution was the following command:我创建了一个新的 EC2 实例,并在安装 lxde 时选择了 gdm3 作为默认显示管理器选项。所以我能够使用 DISPLAY=:1.0 运行 xcalc。但是当运行包含 Tkinter 的应用程序时,我遇到了同样的问题。解决方案是以下命令:

export DISPLAY=:1.0; xhost +

So xhost helps you use the computing power of another machine like an EC2 instance to run a graph and display it on the client screen.因此,xhost 可以帮助您使用另一台机器(如 EC2 实例)的计算能力来运行图形并将其显示在客户端屏幕上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM