python - Gtk* backend requires pygtk to be installed -
from within virtual environment, trying load script uses matplotlib
's gtkagg
backend, fail following traceback:
traceback (most recent call last): file "<stdin>", line 1, in <module> file "/home/user/.virtualenvs/venv/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 97, in <module> _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() file "/home/user/.virtualenvs/venv/local/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup globals(),locals(),[backend_name]) file "/home/user/.virtualenvs/venv/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module> matplotlib.backends.backend_gtk import gtk, figuremanagergtk, figurecanvasgtk,\ file "/home/user/.virtualenvs/venv/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 16, in <module> raise importerror("gtk* backend requires pygtk installed.") importerror: gtk* backend requires pygtk installed.
the code ran in order produce importerror
follows:
import matplotlib mpl mpl.use('gtkagg') import matplotlib.pyplot plt
when running same code after deactivating virtual environment, goes well.
i assumed may due version differences; indeed, such differences exist on machine. however, version in virtual environment newer (1.2.0 versus 1.1.1rc), not expecting less support.
in case not clear: question how allow importing pyplot
gtkagg
backend on new version of matplotlib
, or @ least attempt understand reasons import failure.
you created virtual evn like:
$ virtualenv ~/.virtualenvs/my_env
by default can see none of system-installed packages (including pygtk) when try run mpl rightly complains not have pygtk installed because (with in context of virtualenv) not.
you can either build , install pygtk within virtualenv or can use
$ virtualenv --system-site-packages ~/.virtualenvs/my_env
(doc) make virtualenv inherit global packages.
Comments
Post a Comment