Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pyqt6 #1112

Closed
Battleman opened this issue Nov 3, 2022 · 15 comments · May be fixed by #1549
Closed

Support pyqt6 #1112

Battleman opened this issue Nov 3, 2022 · 15 comments · May be fixed by #1549
Labels
enhancement New feature or request pydevd

Comments

@Battleman
Copy link

Environment data

  • debugpy version: 1.5.1
  • OS and version: GNU/Linux Pop!_OS 22.04
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.9.13, Anaconda 22.9.0
  • Using VS Code or Visual Studio: VS Code (Codium) 1.72.2

Actual behavior

The debugger just "stops" after importing matplotlib, with no sign or crash or error. Just seems to be complete. See the screencast at the end.

Expected behavior

Debugging continues to the next line

Steps to reproduce:

  1. Create a conda environment with python 3.9
  2. Install matplotlib and PyQt6 through pip
  3. Install jupyter through conda
  4. Create a file, and import matplotlib (and anything on the next line)
  5. Put a breakpoint on the matplotlib import
  6. Debug the file
  7. When reaching the breakpoint, Step Over.

To make it easier, here are the minimal reproducible example I could generate:

conda create -y -n bug-report python=3.9
conda activate bug-report
pip install python-xlib matplotlib pyqt6 pillow
conda install -y jupyter

Open VS Code, create a file, enter the following content

import matplotlib.pyplot as plt # <-- put a breakpoint here
raise ValueError("I should get here")

Put the breakpoint, start debugging, step over.

Additional information

It seems removing either of matplotlib, jupyter or PyQt6 solves the problem.

Installing an older version of the Python extension (ms-python.python) also works. v2022.4.1 was the first that caused the issue, while the previous (previous according to VS Code) v2022.2.1924087327 still works.

I could capture the behavior in the following video:
screencast.webm

@fabioz
Copy link
Collaborator

fabioz commented Nov 3, 2022

If you enable faulthandler, does it show any error? -- see: https://docs.python.org/3/library/faulthandler.html for details on how to use it.

Also, can you try with debugpy 1.6.3?

If it still happens with the debugpy 1.6.3, can you provide the logging for that?

See: https://github.com/microsoft/debugpy/wiki/Enable-debugger-logs for details on how to collect the logs.

@Battleman
Copy link
Author

if you enable faulthandler

With the following code I do get a stacktrace:

import faulthandler
faulthandler.enable()

import matplotlib.pyplot as plt
raise ValueError("I should get here")
Stack trace
cd /tmp/mydebug/src ; /usr/bin/env /home/battleman/anaconda3/envs/bug-report/bin/python /home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 40627 -- main.py 
Fatal Python error: Segmentation fault

Thread 0x00007f6c86ffd640 (most recent call first):
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 316 in wait
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 581 in wait
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd.py", line 261 in _on_run
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 49 in run
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 980 in _bootstrap_inner
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 937 in _bootstrap

Thread 0x00007f6c877fe640 (most recent call first):
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 316 in wait
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 581 in wait
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd.py", line 215 in _on_run
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 49 in run
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 980 in _bootstrap_inner
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 937 in _bootstrap

Thread 0x00007f6c87fff640 (most recent call first):
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 312 in wait
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 581 in wait
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_timeout.py", line 43 in _on_run
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 49 in run
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 980 in _bootstrap_inner
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 937 in _bootstrap

Thread 0x00007f6c8cf3e640 (most recent call first):
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 204 in _read_line
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 222 in _on_run
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 49 in run
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 980 in _bootstrap_inner
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 937 in _bootstrap

Thread 0x00007f6c8d73f640 (most recent call first):
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 316 in wait
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/queue.py", line 180 in get
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 367 in _on_run
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 49 in run
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 980 in _bootstrap_inner
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/threading.py", line 937 in _bootstrap

Current thread 0x00007f6c903b5440 (most recent call first):
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydev_ipython/inputhookqt5.py", line 88 in create_inputhook_qt5
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydev_ipython/inputhook.py", line 224 in enable_qt5
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydev_ipython/inputhook.py", line 178 in enable_qt
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydev_ipython/inputhook.py", line 540 in enable_gui
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py", line 30 in do_enable_gui
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd.py", line 1565 in <lambda>
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd.py", line 1581 in _activate_gui_if_needed
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd.py", line 2085 in _do_wait_suspend
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd.py", line 2062 in do_wait_suspend
  File "main.py", line 5 in <module>
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124 in _run_code
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135 in _run_module_code
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321 in run_path
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284 in run_file
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430 in main
  File "/home/battleman/.vscode-oss/extensions/ms-python.python-2022.16.1-universal/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39 in <module>
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/runpy.py", line 87 in _run_code
  File "/home/battleman/anaconda3/envs/bug-report/lib/python3.9/runpy.py", line 197 in _run_module_as_main

debugpy 1.6.3

It seems to still happen. I'm not sure which log is necessary? Here are the ones generated after running and crashing.

debugger.vscode_5a0785b7-36ab-4aac-964d-2a96be337842.log
debugpy.adapter-334179.log
debugpy.launcher-334187.log
debugpy.pydevd.334192.log
debugpy.server-334192.log

@Battleman
Copy link
Author

Something I realized may not have been clear: Running the code works fine, and any breakpoint or stop before importing matplotlib works fine. Breaking at/before the import, then continue the run works just fine, and the code executes. But any "stop" (from a breakpoint, or stepover) after the matplotlib import creates the segfault.

@fabioz
Copy link
Collaborator

fabioz commented Nov 4, 2022

Thanks, faulthandler does show the actual issue:

  File ".../pydevd/pydev_ipython/inputhookqt5.py", line 88 in create_inputhook_qt5
  File ".../pydevd/pydev_ipython/inputhook.py", line 224 in enable_qt5
  File ".../pydevd/pydev_ipython/inputhook.py", line 178 in enable_qt
  File ".../pydevd/pydev_ipython/inputhook.py", line 540 in enable_gui
  File ".../pydevd/pydev_ipython/matplotlibtools.py", line 30 in do_enable_gui
  File ".../pydevd/pydev_ipython/matplotlibtools.py", line 96 in activate_matplotlib

So, the real issue is that it's trying to activate qt5 (so, I guess you have both qt6 and qt5 installed) and when it does that qt crashes.

One thing here is that the debugger doesn't currently support qt6 (I'll rename this issue accordingly).

In the meanwhile, you should be able to set:

"guiEventLoop": "none"

in your launch configuration to avoid the crash.

-- note: this will mean that graphs you create won't be interactive when you're stopped in a breakpoint until qt6 is actually supported -- at which point you should be able to remove that "guiEventLoop": "none" from your launch configuration.

@fabioz fabioz changed the title Debugpy stops with jupyter, pyqt6 and matplotlib installed Support pyqt6 Nov 4, 2022
@Battleman
Copy link
Author

Ah I see. Indeed, when installing jupyter with conda, the two following come along, that I didn't spot:

pyqt               pkgs/main/linux-64::pyqt-5.15.7-py39h6a678d5_1 None
pyqt5-sip          pkgs/main/linux-64::pyqt5-sip-12.11.0-py39h6a678d5_1 None

So PyQt 5.15 ann PyQt5-sip 12.11. Installing jupyterlab (the package I actually need/use) instead of jupyter skips those, and make the environment viable.

The takeaway I get from that is that, more than support for PyQt6, it's the presence of both pyqt6* packages along with pyqt v5 and pyqt5* packages that is problematic. I guess this is expected beyond debugpy.

So either making sure I only have PyQt6 (thus no jupyter), or if necessary downgrading to PyQt5.

Thank you for your kind help!

@MarcosCalvi
Copy link

I am wondering, is the problem the qt_loaders file or is there something more? Sorry for my ignorance but I don't know how debugpy works inside

@int19h
Copy link
Contributor

int19h commented Mar 1, 2023

It's also the input hooks in the same package - that's the part that works with matplotlib.

@MarcosCalvi
Copy link

It's also the input hooks in the same package - that's the part that works with matplotlib.

Ok, thank you, I thought so, it is a shame it is not included PySide6. Do you know if it is in the planning to make it compatible at some point?

@int19h
Copy link
Contributor

int19h commented Mar 3, 2023

It's on the backlog now, but with no specific schedule. Generally speaking, when it comes to features, the ones that are in higher demand (as evidenced by e.g. GitHub upvotes) are scheduled to be implemented first.

@EricAtORS
Copy link

I have the same. I worked around it by deleting the PyQt5 folder.

@MarcosCalvi
Copy link

I have the same. I worked around it by deleting the PyQt5 folder.

What do you mean? In the debugpy installation folder?

@judej
Copy link

judej commented Jan 3, 2024

Thank you for the report. Given our current resources are working on the Python 3.12 debugger, we will not be fixing this issues in the pre Python 3.12 debugger.

@judej judej closed this as completed Jan 3, 2024
@EricAtORS
Copy link

I have the same. I worked around it by deleting the PyQt5 folder.

What do you mean? In the debugpy installation folder?

From my site-packages folder.
I had both pyqt5 and pyqt6. I don't need pyqt5 so I just deleted the pyqt5 folder.

@MironMA
Copy link

MironMA commented Feb 27, 2024

Thank you for the report. Given our current resources are working on the Python 3.12 debugger, we will not be fixing this issues in the pre Python 3.12 debugger.

Since v1.8.1 now supports Python 3.12, would you consider reopening this issue?

@int19h
Copy link
Contributor

int19h commented Feb 27, 2024

To clarify, by "pre-Python 3.12 debugger" we mean not support for a particular Python version, but the use of the new debugging APIs introduced in Python 3.12. While the most recent stable debugpy release supports Python 3.12, its overall architecture is still based on legacy Python APIs, and we are not heavily investing into that codebase at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pydevd
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants