0 votes
1 view
in AWS by (19.2k 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.6k 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.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...