I've been working on a plugin for use with QGIS 3.16. I have developed it locally and I want to now deploy it so others can use it. The problem or rather question I'm having is: How do I deal with dependencies on external packages?

I found this answer: Development of a plugin which depends on an external Python library

and this discussion: http://osgeo-org.1560.x6.nabble.com/A-pipinstall-plugin-is-possible-First-What-s-the-difference-between-the-Osgeo4w-Shell-td5107633.html

But I'm wondering how people handle this right now. I'm pretty new to Python and QGIS both so maybe my concerns just stem from not being informed. Some of the packages I had to install are a little tricky to get working on Windows (geopandas for example), which is the first part I'm not sure how to handle. I've read that installing with conda seems to work reliably, but that doesn't seem to be a viable option since I have no idea whether a user will have conda installed (or am I missing something here?).

I'm basically looking for some documentation/recommendations to handle dependencies semi-gracefully. I would like to avoid changing the users setup if possible, since my plugin might need a different version of some package and another plugin might require a different version. Any tips/good reads on how to go about this?

Is it possible to have the plugin in its own virtual environment for example? Or can I somehow download the necessary packages and include them from a file? For geopandas, that would probably mean also downloading its dependencies, can I then force geopandas to use those versions of packages instead of what might be on the users path? Would you recommend such an approach?

I'm working on Windows by the way, and the plugin does not have to be cross-platform at least for now.

I realize this is a pretty broad question, but I'm hoping to get some tips on where to start looking for a solution.

1 Answer 1


QGIS has written standards for handling external dependencies - they require that the dependencies are clearly stated in the About metadata field. You can include a short guide for installing the python libraries as needed, or link to existing guides. They also suggest that if the dependencies are not available in OSGeo4w Python, that you provide instructions on how to install them on Windows. If your plugin requires libraries with different versions than what the user has, it will be up to the user to create a virtual environment with the correct dependencies and versions.

If you were writing a standalone piece of software, you could package all of your external dependencies as part of the final executable file when you freeze your python application. There are tools like PyInstaller that handle all of the external dependencies so that the user doesn't have to install anything else to make your executable work.

source: https://plugins.qgis.org/publish/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.