@Pedro:
Tried it today on Windows w OSGeo QGIS and failed right away. But in a different way:

If I launch OSGeo QGIS and ask for the python executable's path (sys.executabe), I get 'C:/OSGeo4W/bin/qgis-bin.exe'. which looks like entry point is for QGIS.  So subprocess calls that and a new QGIS window opens.

Not feeling like tackling this and probably other cases.
So back to download+including those bins I reckon.

@Johannes:
Thank you. Yes realizing that now..


Cheers,
Aron



On 06-04-2022 12:12, Johannes Kröger (WhereGroup) wrote:

Trying to find a smart way to install Python dependencies for the users that will not potentially not work or even break stuff is a very hard thing(tm). Check out these two QEPs for a lot of discussion and possible approaches:

https://github.com/qgis/QGIS-Enhancement-Proposals/issues/202
https://github.com/qgis/QGIS-Enhancement-Proposals/issues/179

Cheers, Hannes

Am 06.04.22 um 00:10 schrieb Pedro Camargo via QGIS-Developer:
Hey Aron,
                   I did explore that route, but I found out that it would fail when the user did not have administrator rights (or even if QGIS had not been ran as administrator on Windows).  Did you find it to be different?

Cheers,
Pedro



---- On Wed, 06 Apr 2022 03:28:09 +1000 *Aron Gergely <aron.gerg...@rasterra.nl>* wrote ----

    Thank you, I checked out your plugin - yes that seems also a good
    way.
    I already had the logic to detect, throw message, guide to
    dialog, etc... implemented similar to yours.

    But I wanted to let pip manage the actual package, so I went with
    the subprocess+pip route. Here is a minimum working example:

    import subprocess
    import sys


    try:
         subprocess.check_call((sys.executable, '-m', 'pip', 'install', 
'h3<=3.99'))
    except subprocess.CalledProcessErroras e:
         raise e# handle any errors here instead

    I connected it to a button in a dialog. And catch stdout, stderr
    and the exit code of the subprocess so I can show the user what
    is happening.

    Have not yet tried on other platforms than Linux. But
    sys.executable is there to solve the ambiguity of python
    executable path.


    Best regards,
    Aron


--
Johannes Kröger / GIS-Entwickler/-Berater

---------------------------------------------
Schon gewusst?

In unserem Blog geben wir Tipps & Tricks zu Open-Source-GIS-Software
und berichten aus unserem Experten-Alltag:
https://wheregroup.com/blog/
---------------------------------------------

WhereGroup GmbH
Grevenweg 89
20537 Hamburg
Germany

Tel: +49 (0)228 / 90 90 38 - 36
Fax: +49 (0)228 / 90 90 38 - 11

johannes.kroe...@wheregroup.com
www.wheregroup.com
Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885
-------------------------------
--
Email Signature Kind Regards,

Aron Gergely
+31 (0) 6 38 70 97 66

*Rasterra* | www.rasterra.nl
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to