-
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
When trying to import matplotlib in a jupyter notebook with matplotlib version smaller than 3.5.2 I get an error with the new release version 0.2.1. I understand the insentive of not having the direct dependency but I guess something should be done to prevent this. It works with both, the older matplotlib-inline version as well as newer matplotlib versions (>=3.5.2)
To reproduce
Install dependencies
pip install matplotlib==3.5.1 numpy==1.24.1 jupyterThen open a jupyter notebook and try
import matplotlib.pyplot as pltwhich will yield the following error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import matplotlib.pyplot as plt
File ~\temp\venv\lib\site-packages\matplotlib\pyplot.py:2230
2228 dict.__setitem__(rcParams, "backend", rcsetup._auto_backend_sentinel)
2229 # Set up the backend.
-> 2230 switch_backend(rcParams["backend"])
2232 # Just to be safe. Interactive mode can be turned on without
2233 # calling `plt.ion()` so register it again here.
2234 # This is safe because multiple calls to `install_repl_displayhook`
2235 # are no-ops and the registered function respect `mpl.is_interactive()`
2236 # to determine if they should trigger a draw.
2237 install_repl_displayhook()
File ~\temp\venv\lib\site-packages\matplotlib\pyplot.py:267, in switch_backend(newbackend)
260 # Backends are implemented as modules, but "inherit" default method
261 # implementations from backend_bases._Backend. This is achieved by
262 # creating a "class" that inherits from backend_bases._Backend and whose
263 # body is filled with the module's globals.
265 backend_name = cbook._backend_module_name(newbackend)
--> 267 class backend_mod(matplotlib.backend_bases._Backend):
268 locals().update(vars(importlib.import_module(backend_name)))
270 required_framework = _get_required_interactive_framework(backend_mod)
File ~\temp\venv\lib\site-packages\matplotlib\pyplot.py:268, in switch_backend.<locals>.backend_mod()
267 class backend_mod(matplotlib.backend_bases._Backend):
--> 268 locals().update(vars(importlib.import_module(backend_name)))
File ~\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py:127, in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
File ~\temp\venv\lib\site-packages\matplotlib_inline\__init__.py:1
----> 1 from . import backend_inline, config # noqa
3 __version__ = "0.2.1"
5 # we can't ''.join(...) otherwise finding the version number at build time requires
6 # import which introduces IPython and matplotlib at build time, and thus circular
7 # dependencies.
File ~\temp\venv\lib\site-packages\matplotlib_inline\backend_inline.py:236
231 ip.events.unregister("post_run_cell", configure_once)
233 ip.events.register("post_run_cell", configure_once)
--> 236 _enable_matplotlib_integration()
239 def _fetch_figure_metadata(fig):
240 """Get some metadata to help with displaying a figure."""
File ~\temp\venv\lib\site-packages\matplotlib_inline\backend_inline.py:218, in _enable_matplotlib_integration()
216 backend = matplotlib.get_backend(auto_select=False)
217 else:
--> 218 backend = matplotlib.rcParams._get("backend")
220 if ip and backend in ("inline", "module://matplotlib_inline.backend_inline"):
221 from IPython.core.pylabtools import activate_matplotlib
AttributeError: 'RcParams' object has no attribute '_get'
Metadata
Metadata
Assignees
Labels
No labels