<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>@Pedro:<br>
      Tried it today on Windows w OSGeo QGIS and failed right away. But
      in a different way:<br>
      <br>
      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.<br>
      <br>
      Not feeling like tackling this and probably other cases.<br>
      So back to download+including those bins I reckon.<br>
      <br>
      @Johannes:<br>
      Thank you. Yes realizing that now..<br>
      <br>
      <br>
      Cheers,<br>
      Aron<br>
      <br>
      <br>
      <br>
    </p>
    <div class="moz-cite-prefix">On 06-04-2022 12:12, Johannes Kröger
      (WhereGroup) wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:c9aa596a-dc35-f7f3-7ea5-a8eb1343ddf3@wheregroup.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>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:<br>
        <br>
        <a class="moz-txt-link-freetext"
          href="https://github.com/qgis/QGIS-Enhancement-Proposals/issues/202"
          moz-do-not-send="true">https://github.com/qgis/QGIS-Enhancement-Proposals/issues/202</a><br>
        <a class="moz-txt-link-freetext"
          href="https://github.com/qgis/QGIS-Enhancement-Proposals/issues/179"
          moz-do-not-send="true">https://github.com/qgis/QGIS-Enhancement-Proposals/issues/179</a></p>
      <p>Cheers, Hannes<br>
      </p>
      <div class="moz-cite-prefix">Am 06.04.22 um 00:10 schrieb Pedro
        Camargo via QGIS-Developer:<br>
      </div>
      <blockquote type="cite"
        cite="mid:17ffbc72799.86c43b9f23292.7962298494395626212@margo.co">
        <meta content="text/html; charset=UTF-8"
          http-equiv="Content-Type">
        <div style="font-family: Verdana, Arial, Helvetica, sans-serif;
          font-size: 10pt;">
          <div>Hey Aron,<br>
          </div>
          <div>                   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?<br>
          </div>
          <div><br>
          </div>
          <div>Cheers,<br>
          </div>
          <div>Pedro<br>
          </div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div class="zmail_extra" data-zbluepencil-ignore="true">
            <div><br>
            </div>
            <div id="Zm-_Id_-Sgn1">---- On Wed, 06 Apr 2022 03:28:09
              +1000 <b>Aron Gergely <a class="moz-txt-link-rfc2396E"
                  href="mailto:aron.gergely@rasterra.nl"
                  moz-do-not-send="true"><aron.gergely@rasterra.nl></a></b>
              wrote ----<br>
            </div>
            <div><br>
            </div>
            <blockquote style="border-left: 1px solid rgb(204, 204,
              204); padding-left: 6px; margin: 0px 0px 0px 5px;">
              <div>
                <p>Thank you, I checked out your plugin - yes that seems
                  also a good way.<br>
                  I already had the logic to detect, throw message,
                  guide to dialog, etc... implemented similar to yours.<br>
                  <br>
                  But I wanted to let pip manage the actual package, so
                  I went with the subprocess+pip route. Here is a
                  minimum working example:<br>
                </p>
                <pre style="background-color: rgb(43,43,43);color: rgb(169,183,198);font-family: "JetBrains Mono", monospace;font-size: 9.8pt;"><span class="colour" style="color:rgb(204, 120, 50)">import </span>subprocess
<span class="colour" style="color:rgb(204, 120, 50)">import </span>sys


<span class="colour" style="color:rgb(204, 120, 50)">try</span>:
    subprocess.check_call((sys.executable<span class="colour" style="color:rgb(204, 120, 50)">, </span><span class="colour" style="color:rgb(106, 135, 89)">'-m'</span><span class="colour" style="color:rgb(204, 120, 50)">, </span><span class="colour" style="color:rgb(106, 135, 89)">'pip'</span><span class="colour" style="color:rgb(204, 120, 50)">, </span><span class="colour" style="color:rgb(106, 135, 89)">'install'</span><span class="colour" style="color:rgb(204, 120, 50)">, </span><span class="colour" style="color:rgb(106, 135, 89)">'h3<=3.99'</span>))
<span class="colour" style="color:rgb(204, 120, 50)">except </span>subprocess.CalledProcessError <span class="colour" style="color:rgb(204, 120, 50)">as </span>e:
    <span class="colour" style="color:rgb(204, 120, 50)">raise </span>e  <span class="colour" style="color:rgb(128, 128, 128)"># handle any errors here instead</span>

</pre>
                <p>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.<br>
                  <br>
                  Have not yet tried on other platforms than Linux. But
                  sys.executable is there to solve the ambiguity of
                  python executable path.<br>
                  <br>
                  <br>
                  Best regards,<br>
                  Aron<br>
                  <br>
                  <br>
                </p>
              </div>
            </blockquote>
          </div>
        </div>
      </blockquote>
      <pre class="moz-signature" cols="72">-- 
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:
<a class="moz-txt-link-freetext" href="https://wheregroup.com/blog/" moz-do-not-send="true">https://wheregroup.com/blog/</a>
---------------------------------------------

WhereGroup GmbH
Grevenweg 89
20537 Hamburg
Germany

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

<a class="moz-txt-link-abbreviated moz-txt-link-freetext" href="mailto:johannes.kroeger@wheregroup.com" moz-do-not-send="true">johannes.kroeger@wheregroup.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.wheregroup.com" moz-do-not-send="true">www.wheregroup.com</a>
Geschäftsführer:
Olaf Knopp, Peter Stamm 
Amtsgericht Bonn, HRB 9885
-------------------------------
</pre>
    </blockquote>
    <div class="moz-signature">-- <br>
      <title>Email Signature</title>
      <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
      Kind Regards,<br>
      <br>
      Aron Gergely<br>
      +31 (0) 6 38 70 97 66<br>
      <br>
      <b>Rasterra</b> | <ahref="https: www.rasterra.nl"=""><a class="moz-txt-link-abbreviated" href="http://www.rasterra.nl">www.rasterra.nl</a><a><br>
        </a></ahref="https:></div>
  </body>
</html>