microsoft / microsoft/vscode-python-debugger

Debugger crashes when importing matplotlib with justMyCode set to false

Đang mở
#758 1 bình luận 1 reaction 1 người được giao Xem trên GitHub

@eleanorjboyd đang làm issue này rồi.

Từ ngày 14/8/2025.

~find-duplicates triage-needed
Ngôn ngữ chính
TypeScript
Star
180
Fork
126
Merge trung bình
2 ngày 3 giờ
Pull request đã merge (30 ngày)
3

Mô tả

Environment data

  • Python Debugger version: 2025.6.0
  • debugpy version: 1.8.13
  • OS and version: Window 11, connected with SSH to Ubuntu 22.04.3 LTS (the code runs on the Linux machine)
  • Environment: pixi (conda) environment with python 3.10
  • IDE: Cursur v.1.2.4 (VSCode 1.99.3)

Actual behavior

When trying to debug a code that imports matplotlib with justMyCode set to false (in my user settings), I get this error:

Traceback (most recent call last):
  File "_pydevd_bundle\\pydevd_cython.pyx", line 1090, in _pydevd_bundle.pydevd_cython.PyDBFrame.trace_dispatch
  File "_pydevd_bundle\\pydevd_cython.pyx", line 494, in _pydevd_bundle.pydevd_cython.PyDBFrame.do_wait_suspend
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2188, in do_wait_suspend
    keep_suspended = self._do_wait_suspend(thread, frame, event, arg, trace_suspend_type, from_this_thread, frames_tracker)
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2214, in _do_wait_suspend
    self._activate_gui_if_needed()
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 1676, in _activate_gui_if_needed
    activate_function()
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 1659, in <lambda>
    "matplotlib": lambda: activate_matplotlib(do_enable_gui),
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py", line 138, in activate_matplotlib
    gui, backend = find_gui_and_backend()
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py", line 64, in find_gui_and_backend
    backend = matplotlib.rcParams["backend"]
AttributeError: partially initialized module 'matplotlib' has no attribute 'rcParams' (most likely due to a circular import)
Traceback (most recent call last):
  File "$USER/project/.pixi/envs/default/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "$USER/project/.pixi/envs/default/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in <module>
    cli.main()
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 501, in main
    run()
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 351, in run_file
    runpy.run_path(target, run_name="__main__")
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 310, in run_path
    return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 127, in _run_module_code
    _run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 118, in _run_code
    exec(code, run_globals)
  File "$USER/.cursor-server/data/User/globalStorage/buenon.scratchpads/scratchpads/587806bd8d2d5e49dde1948c853676a7/scratch9.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "$USER/project/.pixi/envs/default/lib/python3.10/site-packages/matplotlib/__init__.py", line 1, in <module>
    """
  File "$USER/project/.pixi/envs/default/lib/python3.10/site-packages/matplotlib/__init__.py", line 1, in <module>
    """
  File "_pydevd_bundle\\pydevd_cython.pyx", line 1697, in _pydevd_bundle.pydevd_cython.SafeCallWrapper.__call__
  File "_pydevd_bundle\\pydevd_cython.pyx", line 634, in _pydevd_bundle.pydevd_cython.PyDBFrame.trace_dispatch
  File "_pydevd_bundle\\pydevd_cython.pyx", line 1112, in _pydevd_bundle.pydevd_cython.PyDBFrame.trace_dispatch
  File "_pydevd_bundle\\pydevd_cython.pyx", line 1090, in _pydevd_bundle.pydevd_cython.PyDBFrame.trace_dispatch
  File "_pydevd_bundle\\pydevd_cython.pyx", line 494, in _pydevd_bundle.pydevd_cython.PyDBFrame.do_wait_suspend
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2188, in do_wait_suspend
    keep_suspended = self._do_wait_suspend(thread, frame, event, arg, trace_suspend_type, from_this_thread, frames_tracker)
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2214, in _do_wait_suspend
    self._activate_gui_if_needed()
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 1676, in _activate_gui_if_needed
    activate_function()
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 1659, in <lambda>
    "matplotlib": lambda: activate_matplotlib(do_enable_gui),
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py", line 138, in activate_matplotlib
    gui, backend = find_gui_and_backend()
  File "$USER/.cursor-server/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py", line 64, in find_gui_and_backend
    backend = matplotlib.rcParams["backend"]
AttributeError: partially initialized module 'matplotlib' has no attribute 'rcParams' (most likely due to a circular import)

Re-setting justMyCode to true allows me to debug (but without stepping into other libraries' code, as I wish to do in many times)

Expected behavior

I wish I could avoid this error 😄

Steps to reproduce:

  1. make sure that justMyCode set to false (e.g, in the user settings)
  2. run this example code I simply pressed the small debugging icon at the top right (Python Debugger: Debug python file):
import matplotlib.pyplot as plt
import numpy as np

# Generate some data
x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x)

# Create the plot
plt.plot(x, y, label='sin(x)')
plt.title('Simple Sine Wave')
plt.xlabel('x')
plt.ylabel('sin(x)')
plt.legend()
plt.grid(True)
plt.show()

thanks!

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.