Matplotlib missing _tkinter

I have problem with running test for matplotlib==2.0.2 even I installed some recommended packages

- sudo apt-get install tk-dev
- sudo apt-get install pkg-config
- sudo apt-get install python-dev
- sudo apt-get install python-tk

I get folowing error:

import matplotlib.pyplot as plt

…/virtualenvs/venv-2.7.9/lib/python2.7/site-packages/matplotlib/ in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
…/virtualenvs/venv-2.7.9/lib/python2.7/site-packages/matplotlib/backends/ in pylab_setup
…/virtualenvs/venv-2.7.9/lib/python2.7/site-packages/matplotlib/backends/ in
from six.moves import tkinter as Tk
…/virtualenvs/venv-2.7.9/lib/python2.7/site-packages/ in load_module
mod = mod._resolve()
…/virtualenvs/venv-2.7.9/lib/python2.7/site-packages/ in _resolve
return _import_module(self.mod)
…/virtualenvs/venv-2.7.9/lib/python2.7/site-packages/ in _import_module
/opt/circleci/.pyenv/versions/2.7.9/lib/python2.7/lib-tk/ in
import _tkinter # If this fails your Python may not be configured for Tk
E ImportError: No module named _tkinter

finally what helped me is having in code calling matplotlib following:

if os.environ.get('DISPLAY', '') == '':
    logging.warning('No display found. Using non-interactive Agg backend.')

and later in in the config suppressing DISPLAY

- unset DISPLAY && python ...

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.