[QGIS-Developer] QGIS plugin depends on pypi package

John Lindsay jlindsay at uoguelph.ca
Fri Jan 19 07:00:40 PST 2024


Hello everyone,

I am developing a new QGIS plugin (https://plugins.qgis.org/plugins/whitebox_workflows_for_qgis/#plugin-manage) that serves as a frontend for a Python geospatial analysis library called Whitebox Workflows for Python (WbW). The plugin seems to work well with on major exception, it requires that the user have WbW installed. It can be installed quite easily using pip (pip install whitebox-workflows), however, I know that QGIS uses its own localized version of Python, which seems to lack a terminal app access (at least on MacOS). Besides, a better solution would be for the plugin to install this package via pip when it is itself first installed and launched. I tried to accomplish this with the following code:

https://github.com/jblindsay/whitebox_workflows_for_qgis/blob/4e463262f6cfd1987afa2f3f7e0e79656eb8d27e/whitebox_workflows_for_qgis_provider.py#L56

This code, which runs whenever the plugin is launched, first checks to see if whitebox_workflows can be imported and if not, it runs pip from the Python script to install it. Unfortunately, some users have reported issues with this not working correctly:

https://github.com/jblindsay/whitebox_workflows_for_qgis/issues/1

[https://opengraph.githubassets.com/a248a1a51b43baa531f4fdf47f85868a01c5785c3dded22234ce269d2c64c9e4/jblindsay/whitebox_workflows_for_qgis/issues/1]<https://github.com/jblindsay/whitebox_workflows_for_qgis/issues/1>
Installation in QGis fails · Issue #1 · jblindsay/whitebox_workflows_for_qgis<https://github.com/jblindsay/whitebox_workflows_for_qgis/issues/1>
AttributeError: 'NoneType' object has no attribute 'write' Traceback (most recent call last): File "C:\\Users/thomas.struller/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins\\whitebox_work...
github.com

So now I'm left trying to figure out what the recommended approach to installing QGIS plugin dependencies is. Any advice from anyone that has successfully dealt with this problem previously? Thanks.

Regards,

John Lindsay



Prof. John Lindsay

Dept. of Geography, Environment & Geomatics,

The University of Guelph,

Room 122, Hutt Building,

E-mail: jlindsay at uoguelph.ca

Phone: (519) 824-4120 ext. 56074

Web: https://geg.uoguelph.ca/faculty/lindsay-john

Research page: https://jblindsay.github.io/ghrg/index.html

WhiteboxTools GIS project: https://www.whiteboxgeo.com/

Twitter: https://twitter.com/whiteboxgeo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240119/e1c073f7/attachment-0001.htm>


More information about the QGIS-Developer mailing list