Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions sciunit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,20 @@ def fix_display(self) -> None:
backend must be changed to one that doesn't need a display.
"""

try:
tkinter.Tk()
except (tkinter.TclError, NameError): # If there is no display.
if tkinter is not None: # tkinter is at least installed
try:
import matplotlib as mpl
except ImportError:
pass
tkinter.Tk()
except (tkinter.TclError, NameError):
pass # It appears that there there is no display.
else:
sciunit.logger.info("Setting matplotlib backend to Agg")
mpl.use("Agg")
return # We can use the tkinter backend.
try:
import matplotlib as mpl
except ImportError:
pass
else:
sciunit.logger.info("Setting matplotlib backend to Agg")
mpl.use("Agg")

def load_notebook(
self, name: str
Expand Down
Loading