arviz-devs / arviz

Exploratory analysis of Bayesian models with Python
https://python.arviz.org
Apache License 2.0
1.61k stars 407 forks source link

1 error in tests preventing all tests from running: _tkinter.TclError: no display name and no $DISPLAY environment variable #2381

Open yurivict opened 2 months ago

yurivict commented 2 months ago

Describe the bug

========================================================================================== ERRORS ===========================================================================================
_____________________________________________________________ ERROR collecting arviz/tests/base_tests/test_plots_matplotlib.py ______________________________________________________________
arviz/tests/base_tests/test_plots_matplotlib.py:139: in <module>
    {"ax": plt.subplots(6, 3)[1]},
/usr/local/lib/python3.11/site-packages/matplotlib/pyplot.py:1598: in subplots
    fig = figure(**fig_kw)
/usr/local/lib/python3.11/site-packages/matplotlib/pyplot.py:934: in figure
    manager = new_figure_manager(
/usr/local/lib/python3.11/site-packages/matplotlib/pyplot.py:465: in new_figure_manager
    return _get_backend_mod().new_figure_manager(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/matplotlib/backend_bases.py:3396: in new_figure_manager
    return cls.new_figure_manager_given_figure(num, fig)
/usr/local/lib/python3.11/site-packages/matplotlib/backend_bases.py:3401: in new_figure_manager_given_figure
    return cls.FigureCanvas.new_manager(figure, num)
/usr/local/lib/python3.11/site-packages/matplotlib/backend_bases.py:1785: in new_manager
    return cls.manager_class.create_with_canvas(cls, figure, num)
/usr/local/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py:486: in create_with_canvas
    window = tk.Tk(className="matplotlib")
/usr/local/lib/python3.11/tkinter/__init__.py:2345: in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
E   _tkinter.TclError: no display name and no $DISPLAY environment variable
================================================================================== short test summary info ==================================================================================
SKIPPED [1] arviz/tests/helpers.py:658: could not import 'bokeh.plotting': No module named 'bokeh'
SKIPPED [1] arviz/tests/external_tests/test_data_beanmachine.py:14: Ignore beanmachine tests until it supports pytorch 2
SKIPPED [1] arviz/tests/helpers.py:658: could not import 'emcee': No module named 'emcee'
SKIPPED [1] arviz/tests/helpers.py:658: could not import 'jax': jax requires jaxlib to be installed. See https://github.com/google/jax#installation for installation instructions.
SKIPPED [1] arviz/tests/external_tests/test_data_pyjags.py:16: Uses deprecated numpy C-api
SKIPPED [1] arviz/tests/helpers.py:658: could not import 'pyro': No module named 'pyro'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================ 6 skipped, 1 error in 8.52s ================================================================================

Version: 0.19.0 Python 3.11 FreeBSD 14.1

OriolAbril commented 2 months ago

From the error it seems related to general matplotlib configuration, not ArviZ specific. Can you run this other test in the same env?

import matplotlib.pyplot as plt

def test_create_subplots():
    fig, ax = plt.subplots(2, 2)
    assert ax.shape == (2, 2)

def test_plot():
    fig, ax = plt.subplots()
    lines = ax.plot([0, 1], [0, 1])
    assert len(lines) == 1