From a0b29498d71b88376ff6e69234919a38cad0f4d8 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 1 Mar 2021 18:21:33 -0500 Subject: [PATCH] Backport PR #19597: Fix IPython import issue --- lib/matplotlib/backend_bases.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 33831c4ba889..3798a936ef75 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1743,7 +1743,7 @@ def _fix_ipython_backend2gui(cls): # `ipython --auto`). This cannot be done at import time due to # ordering issues, so we do it when creating a canvas, and should only # be done once per class (hence the `lru_cache(1)`). - if "IPython" not in sys.modules: + if sys.modules.get("IPython") is None: return import IPython ip = IPython.get_ipython()