I am mainly following
AsgerPetersen's gist and MS's visualstudio python-tutorial and qgis developer_cookbook
-
install this extension pack
-
install ptvsd using the QGIS python3 bin:
cd /Applications/QGIS.app/Contents/MacOS/bin
./python3 -m pip install ptvsd
-
do not install firstaid qqis plugin (or uninstall - see comment below)
-
install lmotta/debug_vs_plugin
-
fork and/or clone a plugin repo and open the repo in vs code
cd "~/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins"
git clone git@github.com:onezoomin/VolumeCalculation.git && cd VolumeCalculation && code .
-
If the repo doesn't already have one, add a debug profile and adapt
6b. Choose the qgis bin folder as Python Interpreter/Applications/QGIS.app/Contents/MacOS/bin
-
Try to set a breakpoint somewhere predictable, eg: on the about button
7b. go to qgis and start the vsdebugger
7c. start debugging session from vs code
7d. use the plugin in qgis in a way that will hit your breakpoint
eg: click the volume calc button and then click about in the dialog
Note: The debugging mode (=stopping at a breakpoint) only worked after deinstalling FirstAid.
Error message in the python console in QGIS:
PYDEV DEBUGGER WARNING:
sys.settrace() should not be used when the debugger is being used.
This may cause the debugger to stop working correctly.
If this is needed, please check:
http://pydev.blogspot.com/2007/06/why-cant-pydev-debugger-work-with.html
to see how to restore the debug tracing back correctly.