Install Tkinter on Amazon Linux

I work on an amazon linux ec2 machine. When I try to run a Python script inside virtualenv, I get the following message:

File "/home/sp/Envs/crispor/local/lib/python2.7/dist-packages/matplotlib/externals/six.py", line 80, in _import_module __import__(name) ImportError: No module named Tkinter 

As I understand it, Tkinter was supposed to be part of the Python installation. But for some reason this is not so. They do not work -

 sudo yum install python-tk sudo yum install tkinter 

How to install tkinter? Or should I do this at all, should it be part of the Python installation?

+7
python linux amazon-ec2 tkinter
source share
3 answers

You do not want (and probably cannot) install tkinter on this server. Set up matplotlib to use a non-interactive backend instead.

Put this in your matplotlibrc file :

 backend : agg 
+23
source share

add to @Goyo. you can also switch mode to agg in code.

 import matplotlib matplotlib.use('agg',warn=False, force=True) from matplotlib import pyplot as plt print "Switched to:",matplotlib.get_backend() 
+4
source share

Could you provide python version information?

1- Try installing this:

 yum install python-tools 

This package uses tkinder, so it can help.

2- If you are using python3:

 sudo yum install python3-tkinter 

3- Download and install the package: http://rpm.pbone.net/index.php3?stat=3&search=python27-tkinter&srodzaj=3&dist[†=79

+1
source share

All Articles