Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Incompatibility to `matplotlib<3.5.2`

Open
#54 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
jupyter-notebook, matplotlib, python

Research direction

Start with matplotlib_inline/backend_inline.py, especially _enable_matplotlib_integration(), and reproduce the reported import using matplotlib==3.5.1, numpy==1.24.1, and jupyter. Done means importing matplotlib.pyplot in a notebook works with matplotlib versions below 3.5.2 without the reported AttributeError.

Written by the indexing model from the issue text.

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 jupyter

Then open a jupyter notebook and try

import matplotlib.pyplot as plt

which 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'
Dominant language
Jupyter Notebook
Stars
31
Forks
39
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ipython/matplotlib-inline

All issues in ipython/matplotlib-inline

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.