Skip to content

Using %matplotlib widget results in `KeyError: 'modifiers'. #12888

@raaaaaymond

Description

@raaaaaymond

Environment data

  • VS Code version:
Version: 1.75.1 (user setup)
Commit: 441438abd1ac652551dbe4d408dfcec8a499b8bf
Date: 2023-02-08T21:32:34.589Z
Electron: 19.1.9
Chromium: 102.0.5005.194
Node.js: 16.14.2
V8: 10.2.154.23-electron.0
OS: Windows_NT x64 10.0.22621
Sandboxed: No
  • Jupyter Extension version (available under the Extensions sidebar): v2023.1.2010391206
  • Python Extension version (available under the Extensions sidebar): v2023.2.0
  • OS (Windows | Mac | Linux distro) and version: Windows 11
  • Python and/or Anaconda version: 3.10.1
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Jupyter server running: Local

Expected behaviour

No errors.

Actual behaviour

The figure shows correctly but there are repeated KeyError: 'modifiers' that makes the output cell extremely long. See screen shot This error does not show when I'm using Jupyter Notebook in my browser (started from the command line), but only in VSCode. Note that the errors appear seconds or sometimes minutes after the figure is shown correctly. In order to reproduce, you must wait a good few seconds after running the code.

JupyterMatplotlibError

Steps to reproduce:

Paste the following code into a cell in a new .ipynb file and run. Note that the errors appear seconds or sometimes minutes after the figure is shown correctly. In order to reproduce, you must wait a good few seconds after running the code in order to see the errors.

%matplotlib widget

import numpy as np
import matplotlib.pyplot as plt

generator = np.random.default_rng()

_, axes = plt.subplots()
random = generator.uniform(0, 1, (1390,))
axes.plot(random)

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

Visual Studio Code (1.75.1, undefined, desktop)
Jupyter Extension Version: 2023.1.2010391206.
Python Extension Version: 2023.2.0.
Workspace folder c:\Users\raaaa\Dev\research
User belongs to experiment group 'jupyterTest'
User belongs to experiment group 'jupyterEnhancedDataViewer'
info 12:22:12.182: LSP Notebooks experiment is enabled
info 12:22:12.596: Find preferred kernel for c:\Users\raaaa\Dev\research\src\python\wtf.ipynb with metadata {"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.1"},"orig_nbformat":4,"vscode":{"interpreter":{"hash":"377ed70cde78874502efeb95ea33073c14a19ade0c532bba2731dee70c0c0238"}}} & preferred interpreter c:\Users\raaaa\AppData\Local\Programs\Python\Python310\python.exe
info 12:22:12.599: Preferred kernel .jvsc74a57bd0377ed70cde78874502efeb95ea33073c14a19ade0c532bba2731dee70c0c0238.c:\Users\raaaa\AppData\Local\Programs\Python\Python310\python.exe.c:\Users\raaaa\AppData\Local\Programs\Python\Python310\python.exe.-m#ipykernel_launcher is exact match or top match for non python kernels, (true, [object Object], true, false)
info 12:22:12.599: PreferredConnection: .jvsc74a57bd0377ed70cde78874502efeb95ea33073c14a19ade0c532bba2731dee70c0c0238.c:\Users\raaaa\AppData\Local\Programs\Python\Python310\python.exe.c:\Users\raaaa\AppData\Local\Programs\Python\Python310\python.exe.-m#ipykernel_launcher found for NotebookDocument: c:\Users\raaaa\Dev\research\src\python\wtf.ipynb
info 12:22:13.024: Process Execution: > ~\AppData\Local\Programs\Python\Python310\python.exe -m pip list
> ~\AppData\Local\Programs\Python\Python310\python.exe -m pip list
info 12:23:09.096: Starting Jupyter Session startUsingPythonInterpreter, .jvsc74a57bd0377ed70cde78874502efeb95ea33073c14a19ade0c532bba2731dee70c0c0238.c:\Users\raaaa\AppData\Local\Programs\Python\Python310\python.exe.c:\Users\raaaa\AppData\Local\Programs\Python\Python310\python.exe.-m#ipykernel_launcher (Python Path: , EnvType: Unknown, EnvName: '', Version: 3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]) for 'c:\Users\raaaa\Dev\research\src\python\wtf.ipynb' (disableUI=false)
info 12:23:09.166: Process Execution: > ~\AppData\Local\Programs\Python\Python310\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~\AppData\Local\Programs\Python\Python310\python.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 12:23:09.196: Process Execution: > ~\AppData\Local\Programs\Python\Python310\python.exe ~\.vscode\extensions\ms-toolsai.jupyter-2023.1.2010391206\pythonFiles\vscode_datascience_helpers\kernel_interrupt_daemon.py --ppid 12504
> ~\AppData\Local\Programs\Python\Python310\python.exe ~\.vscode\extensions\ms-toolsai.jupyter-2023.1.2010391206\pythonFiles\vscode_datascience_helpers\kernel_interrupt_daemon.py --ppid 12504
info 12:23:09.196: Process Execution: cwd: ~\.vscode\extensions\ms-toolsai.jupyter-2023.1.2010391206\pythonFiles\vscode_datascience_helpers
cwd: ~\.vscode\extensions\ms-toolsai.jupyter-2023.1.2010391206\pythonFiles\vscode_datascience_helpers
info 12:23:09.311: Process Execution: > ~\AppData\Local\Programs\Python\Python310\python.exe -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"b650c331-1d7c-4e43-b0ae-d05b32ba4f52" --shell=9002 --transport="tcp" --iopub=9004 --f=c:\Users\raaaa\AppData\Roaming\jupyter\runtime\kernel-v2-12504BotWhtyFiBp9.json
> ~\AppData\Local\Programs\Python\Python310\python.exe -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"b650c331-1d7c-4e43-b0ae-d05b32ba4f52" --shell=9002 --transport="tcp" --iopub=9004 --f=c:\Users\raaaa\AppData\Roaming\jupyter\runtime\kernel-v2-12504BotWhtyFiBp9.json
info 12:23:09.311: Process Execution: cwd: ~\Dev\research\src\python
cwd: ~\Dev\research\src\python
info 12:23:09.496: ipykernel version & path 6.21.2, ~\AppData\Local\Programs\Python\Python310\lib\site-packages\ipykernel\__init__.py for c:\Users\raaaa\AppData\Local\Programs\Python\Python310\python.exe
info 12:23:10.578: Started Kernel Python 3.10.1 (pid: 14092)
info 12:23:10.655: Process Execution: > ~\AppData\Local\Programs\Python\Python310\python.exe ~\.vscode\extensions\ms-toolsai.jupyter-2023.1.2010391206\pythonFiles\printJupyterDataDir.py
> ~\AppData\Local\Programs\Python\Python310\python.exe ~\.vscode\extensions\ms-toolsai.jupyter-2023.1.2010391206\pythonFiles\printJupyterDataDir.py
info 12:23:11.574: �[32mFetch Script for {"moduleName":"jupyter-matplotlib","moduleVersion":"^0.11","requestId":"jupyter-matplotlib:^0.11:1676982191573"}
info 12:23:11.574: �[32mFetch Script for jupyter-matplotlib
info 12:23:11.574: �[32mSearching for Widget Script jupyter-matplotlib#^0.11 using cdns jsdelivr.com unpkg.com
info 12:23:11.729: �[32mWidget Script jupyter-matplotlib#^0.11 found at URI: https://cdn.jsdelivr.net/npm/[email protected]/dist/index.js
info 12:23:11.729: Script source for Widget jupyter-matplotlib@^0.11 was found from source cdn
info 12:23:11.729: �[32mScript for jupyter-matplotlib, is https://cdn.jsdelivr.net/npm/[email protected]/dist/index.js from cdn
info 12:23:11.872: �[32mFetch Script for jupyter-matplotlib
info 12:23:11.872: Script source for Widget jupyter-matplotlib@^0.11 was found from source cdn
info 12:23:11.872: �[32mScript for jupyter-matplotlib, is https://cdn.jsdelivr.net/npm/[email protected]/dist/index.js from cdn

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable buguser-setupIssues caused by incorrectly configured python environments, packages, or the like

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions