I am working on an Amazon Linux ec2 machine. When I try to run a Python script inside a 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 Tkinter should have been a part of the Python installation. But somehow it is not. These do not work -
sudo yum install python-tk
sudo yum install tkinter
How do I install Tkinter? Or should I be doing that at all give it should have been a part of the Python installation?
Could you give python version information?
1- Try to install this:
This package uses tkinder so can help.
2- If you use python3:
3- Download and install the package: http://rpm.pbone.net/index.php3?stat=3&search=python27-tkinter&srodzaj=3&dist[]=79
to add to @Goyo. you can switch the mode to agg in code as well.
You don't want (and probably you can't) install tkinter in that server. Configure matplotlib to use a non-interactive backend instead.
Put this in your
matplotlibrc
file:UPDATE This should not be necessary for matplotlib >= 3.0.0, according to the documentation "[h]eadless linux servers (identified by the DISPLAY env not being defined) will not select a GUI backend".