matplotlib / matplotlib/ipympl

%matplotlib widget run time error

Open
#559 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
1.7k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

Hello,
I saw an old issue about this topic, but I could not find a recent solution.
I am using a Linux machine, Python version 3.12.4. I created my environment and I installed matplotlib by using
`pip install matplotlib`

But when I run my code in VS code, I get a runtime error related to %matplotlib widget

> RuntimeError Traceback (most recent call last)
> File ~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:413, in BackendRegistry.resolve_gui_or_backend(self, gui_or_backend)
> [412](https://file+.vscode-resource.vscode-cdn.net/home/Paola/Documents/~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:412) try:
> --> [413](https://file+.vscode-resource.vscode-cdn.net/home/Paola/Documents/~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:413) return self.resolve_backend(gui_or_backend)
> [414](https://file+.vscode-resource.vscode-cdn.net/home/Paola/Documents/~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:414) except Exception: # KeyError ?
>
> File ~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:375, in BackendRegistry.resolve_backend(self, backend)
> [374](https://file+.vscode-resource.vscode-cdn.net/home/Paola/Documents/~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:374) if gui is None:
> --> [375](https://file+.vscode-resource.vscode-cdn.net/home/Paola/Documents/~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:375) raise RuntimeError(f"'{backend}' is not a recognised backend name")
> [377](https://file+.vscode-resource.vscode-cdn.net/home/Paola/Documents/~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:377) return backend, gui if gui != "headless" else None
>
> RuntimeError: 'widget' is not a recognised backend name
>
> During handling of the above exception, another exception occurred:
>
> RuntimeError Traceback (most recent call last)
> Cell In[3], [line 8](vscode-notebook-cell:?execution_count=3&line=8)
> [3](vscode-notebook-cell:?execution_count=3&line=3) from pathlib import Path
> [5](vscode-notebook-cell:?execution_count=3&line=5) #import ephyviewer
> [6](vscode-notebook-cell:?execution_count=3&line=6) #import spikeinterface_gui as sigui
> ----> [8](vscode-notebook-cell:?execution_count=3&line=8) get_ipython().run_line_magic('matplotlib', 'widget')
> [9](vscode-notebook-cell:?execution_count=3&line=9) get_ipython().run_line_magic('matplotlib', 'inline')
> [10](vscode-notebook-cell:?execution_count=3&line=10) #%matplotlib notebook
> ...
> [414](https://file+.vscode-resource.vscode-cdn.net/home/Paola/Documents/~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:414) except Exception: # KeyError ?
> --> [415](https://file+.vscode-resource.vscode-cdn.net/home/Paola/Documents/~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:415) raise RuntimeError(
> [416](https://file+.vscode-resource.vscode-cdn.net/home/Paola/Documents/~/.conda/envs/s_i/lib/python3.12/site-packages/matplotlib/backends/registry.py:416) f"'{gui_or_backend} is not a recognised GUI loop or backend name")
>
> RuntimeError: 'widget is not a recognised GUI loop or backend name

Have you found a solution for this issue?
thank you

Contributor guide

Open the contributing guide

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.

Research direction

Start by reproducing `%matplotlib widget` in the reported Linux, Python 3.12.4, and VS Code environment, then inspect the backend resolution path shown in `matplotlib/backends/registry.py`. Compare the behavior with the ipympl and Jupyter integration setup; done means the cause and a reproducible resolution are identified for this configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, matplotlib, python, vscode
Domain
frontend, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.