Skip to content

Instantly share code, notes, and snippets.

@gotjoshua
Last active October 31, 2022 18:18
Show Gist options
  • Save gotjoshua/b4e9801185082eb39a2f0d1ae5374ce9 to your computer and use it in GitHub Desktop.
Save gotjoshua/b4e9801185082eb39a2f0d1ae5374ce9 to your computer and use it in GitHub Desktop.
qgis plugin dev on mac os - notes for ide setup

I am mainly following

AsgerPetersen's gist and MS's visualstudio python-tutorial and qgis developer_cookbook

  1. install this extension pack

  2. install ptvsd using the QGIS python3 bin:

cd /Applications/QGIS.app/Contents/MacOS/bin
./python3 -m pip install ptvsd  
  1. do not install firstaid qqis plugin (or uninstall - see comment below)

  2. install lmotta/debug_vs_plugin

  3. 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 .
  1. 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

  2. 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

@regentribe
Copy link

My command in #5 was slightly different:
cd "/Users/korinna/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins"

@regentribe
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment