python - matplotlib equivalent for Ubuntu servers with no GUI? -
i have gui-less cloud server running bitnami-django ubuntu 14.04 lts meant retrieve , graph data users, cannot produce graphs. clear, care graph image produced , saved, not user has option click button save image. such functionality meaningless such server.
on normal ubuntu linux (mate) 14.04 lts, scripts work perfectly, producing matplotlib.pyplot relevant data in gui window save, zoom, rotate , other functionality; on cloud server error, if don't try invoke 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 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> matplotlib.externals.six.moves import tkinter 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 fails python may not configured tk importerror: no module named _tkinter
this continued after installed other dependencies , tried installing tk-dev, tcl-dev, etc. think need alternative matplotlib produce graphs, unless 1 of kind souls knows clever workaround. in advance help.
(quick) edit: i'm aware of , tried fix in save plot image file instead of displaying using matplotlib, on cloud server matter of broken dependency gui in first place, instead of suppressing gui.
this may not actual answer because couldn't test it, seems error comes fact tkinter
tried loaded unsuccessfully. naturaly solution might avoid using tk backend.
there several backends in matplotlib , not meant interactive plotting. you'll with
import matplotlib print matplotlib.rcsetup.non_interactive_bk
(make sure run before importing pyplot). list contains
[u'agg', u'cairo', u'emf', u'gdk', u'pdf', u'pgf', u'ps', u'svg', u'template']
and potentially of might suit case. select 1 of them, use
matplotlib.use('<name of backend>')
(still before importing pyplot)
finally import pyplot , stuff, avoiding plt.show()
. may functionalities not present of backends - needs tested, e.g. saving svg pdf backend not work.
Comments
Post a Comment