Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in AWS by (19.1k points)

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?

1 Answer

0 votes
by (44.3k points)

Put this in your matplotilbrc file:

backend : agg

Also, you can configure it in the code:

import matplotlib

matplotlib.use('agg',warn=False, force=True)

from matplotlib import pyplot as plt

print "Switched to:",matplotlib.get_backend()

Note: This is not necessary for matplotlib >= 3.0.0. According to the MatPlotLib documentation, headless Linux servers will not select a GUI backend.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
asked Oct 3, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Jul 15, 2019 in AWS by yuvraj (19.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...