9

I'm developing a QGIS plugin and I would like to use arrow or requests packages as I'm used to manipulate dates and REST APIs.

QGIS does not come with these packages (at less arrow), so when I try to access my plugin in QGIS I've got :

"ImportError: No module named arrow"

How can I specify my requirements?

sgillies
  • 9,056
  • 1
  • 33
  • 41
Guts
  • 612
  • 1
  • 6
  • 12
  • 3
    package the egg of the modules with the plugin... or intercept the error and notify the user to install the missing packages – Luigi Pirelli Dec 23 '15 at 16:52
  • R has packages, Python has modules and if you use a Windows version, they are difficult to install (particularly with the standalone QGIS version, see How to install 3rd party python libraries for QGIS on Windows?) – gene Dec 23 '15 at 17:54
  • 2
    In Boundless plugis you can find a way to package module in the same plugin. e.g. read this code https://github.com/boundlessgeo/qgis-geoserver-plugin – Luigi Pirelli Dec 24 '15 at 08:57
  • @gene python has packages and modules - http://stackoverflow.com/questions/7948494/whats-the-difference-between-a-python-module-and-a-python-package – user2856 Dec 24 '15 at 11:09
  • 1
    @LuigiPirelli if you find the time, it would be great if you could summarize the necessary steps to package a module in a plugin in an answer to this question. Thanks a lot! – underdark Dec 25 '15 at 22:00
  • @underdark I'll try to summarise what is wrote in the paver script... btw paver is only used to authomatize the egg generation process. All the stuff is standard python egg generation – Luigi Pirelli Jan 04 '16 at 09:37

1 Answers1

3

Thanks for the resources. I tried to use paver but it seems to be a bit painful to implement, for a non-expert developer, no?

Furthermore, by default, pip is not installed even with the OSGeo4W installer. Could you paver script works without it?

To install it, I followed these instructions and I produced a batch file (see below) but doesn't solve the admin rights problems:

@echo off
Title "PyPi in QGIS"
Echo "Adding 3rd party modules in QGIS"

REM securely download get-pip install script
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

REM install pip
python get-pip.py

REM install 3rd party modules
pip install --user arrow
pip install --user requests
pip install --user requests[security]

@echo on
pause
Guts
  • 612
  • 1
  • 6
  • 12
  • 2
    To install into user python directory (no admin rights needed) you can add --user switch into your command: pip install --user arrow and etc. – Dmitry Baryshnikov Jun 06 '17 at 07:31