Search code examples
pythonqgisminiconda

How to allow QGIS plugin to see local repo changes?


How can the QGIS python plugin environment be directed to use a local git repo for a specific dependency rather than its default site-packages cache?

Context:

I’m working on two local git repos in QGIS python environment: 1) a custom plugin, and 2) a custom module the plugin imports.

Changes to the plugin code are recognized by reloading the plugin via QGIS. However, changes to the module aren’t being recognized by the plugin, and it’s not clear how to instruct QGIS (or conda) where to look.

I’m running Windows 11, Python miniconda3.


Solution

  • Two solutions discovered to date:

    1. create a python virtual environment (where QGIS is launched) within the local git repo
    2. create a .pth file in the virtual environment’s site-packages directory pointing QGIS to the local git repo

    Both of these solutions seem to work well enough, but it’s clear from other SO posts that the first is suboptimal. Not clear whether the second is truly best practice, or whether a third alternative would be.