I have a GUI-less cloud server running Bitnami-Django Ubuntu 14.04 LTS that is meant to retrieve and graph data for users, but it cannot produce the graphs. To be clear, I only care that the graph image is produced and saved, not that a user has an option to click a button to save the image. Such functionality would be meaningless for such a server.
On my normal Ubuntu Linux (Mate) 14.04 LTS, the scripts work perfectly, producing a matplotlib.pyplot from the relevant data in a GUI window with save, zoom, rotate and other functionality; however on the cloud server I get this error, even if I don't try to invoke the show() function:
bitnami@StockPredix:/opt/bitnami/apps/django/django_projects/Project$ python api-test_volume.py
Traceback (most recent call last):
File "api-test_volume.py", line 8, in <module>
import matplotlib.pyplot as plt
File "/opt/bitnami/python/lib/python2.7/site-packages/matplotlib/pyplot.py", line 114, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/opt/bitnami/python/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/opt/bitnami/python/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from matplotlib.externals.six.moves import tkinter as Tk
File "/opt/bitnami/python/lib/python2.7/site-packages/matplotlib/externals/six.py", line 199, in load_module
mod = mod._resolve()
File "/opt/bitnami/python/lib/python2.7/site-packages/matplotlib/externals/six.py", line 113, in _resolve
return _import_module(self.mod)
File "/opt/bitnami/python/lib/python2.7/site-packages/matplotlib/externals/six.py", line 80, in _import_module
__import__(name)
File "/opt/bitnami/python/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
This continued even after I installed other dependencies and tried installing tk-dev, tcl-dev, etc. I think I will need an alternative to matplotlib to produce the graphs, unless one of you kind souls knows a clever workaround. Thanks in advance for your help.
(Quick) Edit: I'm aware of and tried the fix in Save plot to image file instead of displaying it using Matplotlib, but on my cloud server this is a matter of broken dependency with the GUI in the first place, instead of just suppressing the GUI.