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()