My setup uses Ubuntu 22.04 running on Windows WSL2, which suppots executing GUI applications.
NOTE: I'm using VS Code Python Debugger extension version v2024.12.0 (ms-python.debugpy
), which uses debugpy.
In my setup I'm running QGIS built from source, following the official instructions.
My build is under /home/giohappy/dev/qgis/QGIS/build
.
I start VS Code from the plugin folder. In my case I'm testing QGISGeoNodePlugin that I have cloned from Github.
{
"terminal.integrated.env.linux": {
"PYTHONPATH": "/home/giohappy/dev/qgis/QGIS/build/output/python",
},
"python.analysis.include": [
"/home/giohappy/dev/qgis/QGIS/build/output/python"
],
"python.analysis.extraPaths": [
"/home/giohappy/dev/qgis/QGIS/build/output/python"
]
}
NOTE: PyQT5 is installed on the machine, since they have been installed from apt
to build QGIS form source, so I don't need to add it to the settings.
Remote debugger configuration for debugpy
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": {
"port": 5678,
}
}
]
}
From the plugin folder (e.g. /home/giohappy/dev/qgis/QGISGeoNodePlugin
) run:
- `python -m venv venv && ./venv/bin/activate && pip install poetry
pip install .
to install the build depspython pluginadmin.py build
The plugin will be created under the build
folder.
Then we symlink the plugin to the QGIS plugins folder:
ln -s /home/giohappy/dev/qgis/QGISGeoNodePlugin/build/qgis_geonode/ /home/giohappy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis_geonode
The DebuVS QGIS Plugin needs debugpy
.
I have installed it globallty with pip3 install debugy
.
Then: )
- Run QGIS
- Enable the plugin from the Plugins Installer, if not yet enabled
- Under the plugins menu click "Enable Debuf for Visual Studio"
- If all goes fine the message bar should print "INFO DebugVS : Remote Debug for Visual Studio is running("request": "enable_attach", "Port": 5678, "host": "localhost")"
Now you should be ready to debug!
In VS Code
- start debugging using the
Python: Remote Attach
configuration defined above. - Place the breakpoints inside the code inside the build folder.
Now you should be able to step debug in VS Code