[QGIS-Developer] External python package dependency in plugins

shiva reddy kotishiva at gmail.com
Sat Jul 7 04:26:00 PDT 2018


Thanks,
In OS X following works:
subprocess.call(['pip3','install','pyxform'])

Does same works  works for Ubuntu/linux also?


for windows, I am assuming 'python' refers to python 3 inside QGIS3.


regards,

Thanks & Regards
Shiva Reddy K.
Scientist/Engineer 'SC'
Indian Institute of Remote Sensing,
Indian Space Research Organisation
Department of Space
4-Kalidas Road
Dehradun
mobile: 8791806093


On Sat, Jul 7, 2018 at 3:15 PM Richard Duivenvoorde <rdmailings at duif.net>
wrote:

> On 07/07/2018 08:11 AM, shiva reddy wrote:
> >     Hello,
> >     I tried to install automatically during my pluign (QRealTime)
> >     installation by calling:
> >
> >      subprocess.call(['python','-m','install','pyxform','--user'])
> >
> >     It worked many times in windows and it fails sometime.
> >     It don't work in OS X and I have not tested in ubuntu.
> >
> >     What is the best practice for such situation?
>
> Hi, I tried your lines here on Debian 9.4/testing/ in a python3 console:
>
> >>> import subprocess
> >>> subprocess.call(['python','-m','install','pyxform','--user'])
> /usr/bin/python: No module named install
> 1
> >>> subprocess.call(['python','-m','pip','install','pyxform','--user'])
> /usr/bin/python: No module named pip
> 1
>
> Ah, but with Debian we have python and python 3, so I tried:
> subprocess.call(['python3','-m','pip','install','pyxform','--user'])
> ...
> Installing collected packages: argparse, linecache2, traceback2, six,
> unittest2, formencode, unicodecsv, xlrd, pyxform
> Successfully installed argparse-1.4.0 formencode-1.3.1 linecache2-1.0.0
> pyxform-0.11.3 six-1.11.0 traceback2-1.4.0 unicodecsv-0.14.1
> unittest2-1.1.0 xlrd-1.1.0
> 0
> Works! \o/
> Not sure if (from within python) you can find out what the name of the
> python executable is...
>
> For QGIS2 we earlier recommended to just add the full module into your
> plugin package. (if possible, aka python-only module).
>
> There has also been discussion about using pip for python modules, by
> adding the 'pip install line' as a separate metadata.txt line.
> In that way we could either let users install it (in their global or
> user env), or maybe later do this programatically.
>
> There are questions/discussions/options:
> - how to handle clashing specific versions of the same module between
> different plugins
> - where to install modules: installation system wide, in one QGIS
> virtual environment (venv) or in a venv per plugin
> - security questions (mostly a Linux discussion: should a distribution
> rely on venv's or only install distribution modules)... etc
>
> Your idea is (to me) new :-)
> If working platform independently and full proof, I think it is an
> interesting option!
>
> Now with QGIS3 we have true separated profiles, we an idea would be to
> add a virtual environment PER profile, so all plugins can install
> modules in that environment (using your trick?), and in case of a clash
> can then create 2 profiles for those plugins/modules.
> Not sure though this is feasible for all OS's. I think it will be
> easiest on Linux...
>
> Others?
>
> Regards,
>
> Richard Duivenvoorde
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180707/88daf992/attachment.html>


More information about the QGIS-Developer mailing list