5

I am desperately trying to make tkinter work on my EC2 instance.

I just want to be able to execute this line in python:

from tkinter import * 

or this one for older version as from what I understood before python 3.x you had to use a capital T

from Tkinter import *

Right now both these commands return this:

ImportError: No module named _Tkinter

Here are the steps I took and what I found in my research:

  • The python version currently running on my instance is python 2.6.8, thinking that tkinter might not come with this version I decided to install python version to 3.2 (keeping 2.6.8) using this http://www.hosting.com/support/linux/installing-python-3-on-centosredhat-5x-from-source/

  • Then running python 3.2 I ran in the same problem it tells me no module called tkinter.

  • I then tried to install tkinter using a lot of different commands:

    yum install tkinter

    yum install Tkinter

    yum install python-tk

    yum install python3-tk

    yum install tk-devel

    yum install gtk2-devel

    yum install pygtk2-devel

All of these give me the same result:

No package (name of the package) available.

Also in my python 3.2 folder in /opt (the second one I have installed) there is a folder called tkinter but it still seems that somehow python3 does not see it.

What am I missing? Whys can't I import tkinter when I am in python?

xiº
  • 4,605
  • 3
  • 28
  • 39
user2041389
  • 63
  • 2
  • 6

2 Answers2

4

Tkinter requires a display. Unless you can somehow access a desktop on the AWS instance, you won't be able to load tkinter, much less use it.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • This makes sense. I did not thought about this at all but you are totally right I can not use tkinter in this case... – user2041389 Sep 09 '13 at 20:38
1

After the previous answers I realized why it was not working so I made it work using an EC2 Ubuntu instance and doing the following:

  export DEBIAN_FRONTEND=noninteractive
  sudo -E apt-get update
  sudo -E apt-get install -y ubuntu-desktop
  sudo add-apt-repository ppa:freenx-team
  sudo apt-get update
  sudo aptitude install -y freenx
  wget https://bugs.launchpad.net/freenxserver/+bug/576359/+attachment/1378450/+files/nxsetup.tar.gz
  tar -xvf nxsetup.tar.gz
  sudo cp nxsetup /usr/lib/nx/nxsetup
  sudo /usr/lib/nx/nxsetup --install 

Then said no when asked for a password and did:

  sudo vi /etc/ssh/sshd_config and set PasswordAuthentication to yes
  sudo /etc/init.d/ssh restart
  sudo passwd ubuntu
  sudo apt-get install gnome-session-fallback

Once this was done I installed NX client on my local machine. All this thanks to this page

Connected to my new server where I was able to install python-tk like that:

 sudo apt-get install python-tk

And now I can use tkinter on my instance :)

Community
  • 1
  • 1
user2041389
  • 63
  • 2
  • 6