question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugger raises a KeyError referencing matplotlib.pyplot

See original GitHub issue

Issue Type: Bug

Backend TkAgg is interactive backend. Turning interactive mode on.
Traceback (most recent call last):
  File "c:\Users\ratanase\.vscode\extensions\ms-python.python-2018.9.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_frame.py", line 649, in trace_dispatch
    self.do_wait_suspend(thread, frame, event, arg)
  File "c:\Users\ratanase\.vscode\extensions\ms-python.python-2018.9.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_frame.py", line 134, in do_wait_suspend
    self._args[0].do_wait_suspend(*args, **kwargs)
  File "c:\Users\ratanase\.vscode\extensions\ms-python.python-2018.9.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 819, in do_wait_suspend
    self._activate_mpl_if_needed()
  File "c:\Users\ratanase\.vscode\extensions\ms-python.python-2018.9.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 442, in _activate_mpl_if_needed
    activate_function = self.mpl_modules_for_patching.pop(module)
KeyError: 'matplotlib.pyplot'
Traceback (most recent call last):
  File "c:\Users\ratanase\.vscode\extensions\ms-python.python-2018.9.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_trace_dispatch_regular.py", line 316, in __call__
    ).trace_dispatch(frame, event, arg)
  File "c:\Users\ratanase\.vscode\extensions\ms-python.python-2018.9.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_frame.py", line 649, in trace_dispatch
    self.do_wait_suspend(thread, frame, event, arg)
  File "c:\Users\ratanase\.vscode\extensions\ms-python.python-2018.9.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_frame.py", line 134, in do_wait_suspend
    self._args[0].do_wait_suspend(*args, **kwargs)
  File "c:\Users\ratanase\.vscode\extensions\ms-python.python-2018.9.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 819, in do_wait_suspend
    self._activate_mpl_if_needed()
  File "c:\Users\ratanase\.vscode\extensions\ms-python.python-2018.9.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 442, in _activate_mpl_if_needed
    activate_function = self.mpl_modules_for_patching.pop(module)
KeyError: 'matplotlib.pyplot'

VS Code version: Code 1.28.1 (3368db6750222d319c851f6d90eb619d886e08f5, 2018-10-11T18:13:53.910Z) OS version: Windows_NT x64 10.0.17763

System Info
Item Value
CPUs Intel® Core™ i7-7700 CPU @ 3.60GHz (8 x 3600)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 47.79GB (29.09GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (19)
Extension Author (truncated) Version
gitdiffer aag 0.0.3
scope-bar amo 0.1.0
vscode-python-docstring aza 0.0.5
jupyter don 1.1.4
xml Dot 2.3.2
gitlens eam 8.5.6
compareit in4 0.0.2
vscode-line-endings jha 0.1.0
nbpreviewer jit 1.0.0
binary-viewer mom 0.0.1
python ms- 2018.9.1
csharp ms- 1.16.2
PowerShell ms- 1.9.0
autodocstring njp 0.2.3
partial-diff ryu 1.4.0
git-merger sha 0.4.1
vscodeintellicode Vis 1.0.5
markdown-all-in-one yzh 1.6.2
t4-support zbe 0.4.2

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
brettcannoncommented, Oct 29, 2018

@joseortiz3 we don’t support multi-process debugging yet (it’s coming).

1reaction
rtanasecommented, Oct 23, 2018

it might be coming from matplotlib, but I’m not sure. The funny thing is that it’s not always reproducible, for the same script it was working fine initially, then subsequent debugging sessions on the same script was giving me this error. After it started throwing the error, than any other debug retries would have the same result until I kill the Microsoft.Python.LanguageServer.exe process.

Also, in the original bug that I created on the general vscode repo, another user commented that they’re seeing same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

matplotlib animation blit=True causes KeyError - Stack Overflow
After some debugging at home, I've found the answer to my own question. I suspect it is a bug in ipython, but I...
Read more >
PyCharm debugger crashes while patching matplotlib.pyplot
As much as I read the code it seems that the problem is caused by race condition: some thread modifies the dict "mpl_modules_for_patching"...
Read more >
keyerror in Python – How to Fix Dictionary Error
When working with dictionaries in Python, a KeyError gets raised when you try to access an item that doesn't exist in a Python...
Read more >
Python 2.1 Quick Reference
(1) KeyError is raised if key k is not in the map (2) Keys and values are listed in random order...
Read more >
Exception handing and debugging in Python
Exceptions are raised by different kinds of errors arising when executing Python code. In your own code, you may also catch errors, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found