From 543b2d58d4ac1035b59b6f7ea17be36ad468706d Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Fri, 21 Sep 2018 13:08:51 -0700 Subject: [PATCH] FIX: dont' check for interactive framework if none required --- lib/matplotlib/pyplot.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index cb45bf43b738..191e24e6a6b5 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -211,14 +211,15 @@ def switch_backend(newbackend): newbackend, Backend.backend_version) required_framework = Backend.required_interactive_framework - current_framework = \ - matplotlib.backends._get_running_interactive_framework() - if (current_framework and required_framework - and current_framework != required_framework): - raise ImportError( - "Cannot load backend {!r} which requires the {!r} interactive " - "framework, as {!r} is currently running".format( - newbackend, required_framework, current_framework)) + if required_framework is not None: + current_framework = \ + matplotlib.backends._get_running_interactive_framework() + if (current_framework and required_framework + and current_framework != required_framework): + raise ImportError( + "Cannot load backend {!r} which requires the {!r} interactive " + "framework, as {!r} is currently running".format( + newbackend, required_framework, current_framework)) rcParams['backend'] = rcParamsDefault['backend'] = newbackend