简体   繁体   中英

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:

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:

ip_address:1

So I get the following error when running python code:

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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