Incompatibility to `matplotlib<3.5.2`

Ouverte
#54 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
jupyter-notebook, matplotlib, python

Piste de recherche

Commencez par matplotlib_inline/backend_inline.py, en particulier _enable_matplotlib_integration(), et reproduisez l’import signalé avec matplotlib==3.5.1, numpy==1.24.1 et jupyter. Le travail est terminé lorsque l’import de matplotlib.pyplot dans un notebook fonctionne avec des versions de matplotlib antérieures à 3.5.2 sans l’AttributeError signalé.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

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'
Langage dominant
Jupyter Notebook
Étoiles
31
Forks
39
Métriques de merge des PR
Aucune PR mergée en 30 j

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de ipython/matplotlib-inline

Toutes les issues de ipython/matplotlib-inline

Issues similaires

Plus d'issues Backend & API Design

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.