In QGIS install the plugin debugvs
.
The debugvs
plugin needs the python module ptvsd
to function. This module is not installed by default.
In principle you just pip install ptvsd
in the python interpreter used by QGIS.
I am using the QGIS OSX installer from Lutra Consulting. This installer works really great, but installing additional python modules is not very easy.
What I did was this:
- Download the
ptvsd
wheel from pypi. I tried with the newest version (4.2.4), but that didnt work for me. I ended up using ptvsd-4.1.4.zip. - Unzip the wheel (if it has the extension
.whl
then rename it to.zip
) - Inside the zip there are two directories. Copy the directory
ptvsd
to theResources/python
of your QGIS installation. In my case this was/Applications/QGIS3.6.app/Contents/Resources/python/
.
Restart QGIS.
The default remote debugger configuration in VS Code looks like this
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
},
I had to change the pathMappings
to get it to work:
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}"
}
]
},
- In QGIS click
Plugins -> Enable Debug for Visual Studio -> Enable Debug for Visual Studio
- You should now see a message in the QGIS message bar saying something like
DebugVS : Run the Debug in Visual Studio(Python:Attach)
- In VS Code start debugging using the
Python: Remote Attach
configuration defined above.
Now you should be able to set breakpoints in VS Code.
Hi
I get the same 8 errors when I start the debug plugin. It also opens a new instance of qgis. I have been fighting this all day without luck.
am using qgis 3.34.1 on windows 10
as far as I know we dont need to install pvtsd with the current version of the plugin. either way we get the same 8 errors here.
2024-01-14T18:44:30 CRITICAL Invalid Data Source : C:\Users\Operator\AppData\Roaming\Python\Python39\site-packages\debugpy\adapter is not a valid or recognized data source.
2024-01-14T18:44:30 CRITICAL Invalid Data Source : C:\Users\Operator\Documents--for-server is not a valid or recognized data source.
2024-01-14T18:44:30 CRITICAL Invalid Data Source : C:\Users\Operator\Documents\49899 is not a valid or recognized data source.
2024-01-14T18:44:30 CRITICAL Invalid Data Source : C:\Users\Operator\Documents--host is not a valid or recognized data source.
2024-01-14T18:44:30 CRITICAL Invalid Data Source : C:\Users\Operator\Documents\localhost is not a valid or recognized data source.
2024-01-14T18:44:30 CRITICAL Invalid Data Source : C:\Users\Operator\Documents--port is not a valid or recognized data source.
2024-01-14T18:44:30 CRITICAL Invalid Data Source : C:\Users\Operator\Documents\5678 is not a valid or recognized data source.
2024-01-14T18:44:30 CRITICAL Invalid Data Source : C:\Users\Operator\Documents--server-access-token is not a valid or recognized data source.
2024-01-14T18:44:30 CRITICAL Invalid Data Source : C:\Users\Operator\Documents\b8f00babbe3d5c52c125545fafdad7f044eaa73b1ecac8671d6c01aa3d6bd75c is not a valid or recognized data source.
2024-01-14T18:48:47 WARNING Python error : An error has occurred while executing Python code: See message log (Python Error) for more details.