Install Tkinter on Amazon Linux

Install and make tkinter work on AWS EC2 instance

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 :)

No module named tkinter on amazon ec2 centOS

Assuming that you don't want a GUI at all, but let matplotlib produce images on your server, the following might help:

Using a backend without interactive elements should not require tkinter to be present at all.

From the documentation:

There are two types of backends: user interface backends [...] and hardcopy backends to make image files (PNG, SVG, PDF, PS; also referred to as “non-interactive backends”).

Two ways to set the backend (also taken from the link above):

  1. The backend parameter in your matplotlibrc file (see Customizing matplotlib):

    backend : Agg  
  2. Inside the script

    import matplotlib
    matplotlib.use('Agg')

    If you use the use() function, this must be done before importing matplotlib.pyplot.

Possible non-interactive backends:

Sample Image

Add Tkinter to AWS Lambda

You aren't going to be able to run tkinter on AWS lambda. Tkinter requires a display.

Tkinter: Python may not be configured for Tk

According to http://wiki.python.org/moin/TkInter :

If it fails with "No module named _tkinter", your Python configuration needs to be modified to include this module (which is an extension module implemented in C). Do not edit Modules/Setup (it is out of date). You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.

Why is there no tkinter distribution found?

The Tkinter library comes in default with every Python installation

Try this:

import Tkinter as tk

Don't understand this No module named 'tkinter' error

You should run matplotlib with a non-interactive backend on a EC2 server as EC2 is headless. Configure your matplotlibrc file with this line.

backend : agg

To know more about this file, follow this link.



Related Topics



Leave a reply



Submit