[Qgis-user] Problem loading several provider libs from external script

Nils Olaf de Reus nils.de.reus at gmail.com
Tue Feb 26 01:08:54 PST 2013


Thank you for the suggestions. Unfortunately, they did not fix things
on my system -- I checked with  # ldconfig -v | grep "qgis/plugins" -A
30   , and it looks like all my libs are there and thus known to
ldconfig. I then tried again after explicitly setting those
environment variables, and it still gives me only those three (gdal,
gpx, delimitedtext) that I had before, and none of the rest that
should be there.

It would be nice (in a way) if I could call this a 'it must just be
something with my system' issue, but I am aware of two others who have
this exact same problem on theirs.

Also.. I'm still puzzled what would make a library fail to load for
Qt's QLibrary class from a regular python console, yet succeed to load
when in the embedded console of QGIS.

Kind regards,
Nils



On Tue, Feb 26, 2013 at 12:15 AM, Gary Sherman <gsherman at geoapt.com> wrote:
> Try setting QGIS_PREFIX_PATH=/usr
>
> Then make sure the path to the QGIS libs is either configured in
> ld.so.conf.d/ or LD_LIBRARY_PATH
>
> In my case, I have QGIS installed in /home/gsherman/qgis_master and this
> sequence works:
>
> From the shell:
> export LD_LIBRARY_PATH=/home/gsherman/qgis_master/lib
> export QGIS_PREFIX_PATH=/home/gsherman/qgis_master
> export PYTHONPATH=/home/gsherman/qgis_master/share/qgis/python
>
> In Python:
>
> app = QgsApplication(['/home/gsherman/qgis_master'], False)
> app.initQgis()
> for provider in QgsProviderRegistry.instance().providerList():
>     print provider
>    ...:
> WFS
> delimitedtext
> gdal
> gpx
> memory
> mssql
> ogr
> osm
> ows
> postgres
> spatialite
> sqlanywhere
> wcs
> wms
>
>
>
> On Mon, Feb 25, 2013 at 12:45 AM, Nils Olaf de Reus <nils.de.reus at gmail.com>
> wrote:
>>
>> Hi everyone,
>>
>> When trying to use the qgis libraries from an external script (that
>> is, a script running not within the context of the embedded console of
>> QGIS), I get only a severely limited selection of available data
>> providers. A number of libraries that load fine from inside the
>> context of QGIS' embedded python console, fail to load when initQgis
>> is used from a standalone external script.
>>
>> I have a Linux 2.6.32-5-amd64 x86_64 GNU/Linux platform, running
>> Debian Squeeze and the 1.8 release of QGIS for Squeeze from the
>> official repository at http://qgis.org/debian. To test if the problem
>> described below still existed with a newer version of QGIS, I created
>> a clean Debian Squeeze chroot environment, and installed the latest
>> nightly build. The problem still existed with the nightly, same as in
>> the 1.8 release.
>>
>>
>> The provider lib files are present in the usual plugin directory:
>>
>> nils at fennek:~$ ls /usr/lib/qgis/plugins
>> libcoordinatecaptureplugin.so  libmemoryprovider.so
>> libdelimitedtextplugin.so      libmssqlprovider.so
>> libdelimitedtextprovider.so    libofflineeditingplugin.so
>> libdiagramoverlay.so           libogrprovider.so
>> libdxf2shpconverterplugin.so   liboracleplugin.so
>> libevis.so                     libosmprovider.so
>> libgdalprovider.so             libpostgresprovider.so
>> libgeorefplugin.so             librasterterrainplugin.so
>> libgpsimporterplugin.so        libroadgraphplugin.so
>> libgpxprovider.so              libspatialiteprovider.so
>> libgrassplugin.so              libspatialqueryplugin.so
>> libgrassprovider.so            libspitplugin.so
>> libgrassrasterprovider.so      libwfsprovider.so
>> libheatmapplugin.so            libwmsprovider.so
>> libinterpolationplugin.so      libzonalstatisticsplugin.so
>>
>>
>> My external script goes through the usual steps, shown below in an
>> interactive session for easy replication:
>>
>> nils at fennek:~$ python
>> Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
>> [GCC 4.4.5] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> from qgis.core import *
>> >>> app = QgsApplication([u'/usr'], False)
>> >>> print app.showSettings()
>> Application state:
>> Prefix:         /usr
>> Plugin Path:            /usr/lib/qgis/plugins
>> Package Data Path:      /usr/share/qgis
>> Active Theme Name:
>> Active Theme Path:      :/images/themes//
>> Default Theme Path:     :/images/themes/default/
>> SVG Search Paths:       /usr/share/qgis/svg/
>>                 /home/nils/.qgis//svg/
>> User DB Path:   /usr/share/qgis/resources/qgis.db
>>
>> >>> app.initQgis()
>>
>> Now if I check which providers are there, I only get three..
>>
>> >>> for provider in QgsProviderRegistry.instance().providerList():
>> ...     print provider
>> ...
>> delimitedtext
>> gdal
>> gpx
>>
>>
>> ..while that exact same statement inside Qgis' embedded Python Console
>> yields all thirteen providers:
>>
>> >>> for provider in QgsProviderRegistry.instance().providerList():
>> ...     print provider
>> ...
>> WFS
>> delimitedtext
>> gdal
>> gpx
>> grass
>> grassraster
>> memory
>> mssql
>> ogr
>> osm
>> postgres
>> spatialite
>> wms
>>
>>
>> Sofar, I've traced it to the point where during initQgis(), the
>> creation of the QgsProviderRegistry will reject those libraries that
>> return False on the test if QLibrary's load() method will succesfully
>> load them. This too can be shown from the interactive python console.
>> First in the external console:
>>
>> >>> from PyQt4 import QtCore
>> >>>
>> >>> QtCore.QLibrary(u'/usr/lib/qgis/plugins/libdelimitedtextprovider.so').load()
>> True
>> >>> QtCore.QLibrary(u'/usr/lib/qgis/plugins/libgdalprovider.so').load()
>> True
>> >>> QtCore.QLibrary(u'/usr/lib/qgis/plugins/libgpxprovider.so').load()
>> True
>> >>> QtCore.QLibrary(u'/usr/lib/qgis/plugins/libogrprovider.so').load()
>> False
>> >>>
>> >>> QtCore.QLibrary(u'/usr/lib/qgis/plugins/libspatialiteprovider.so').load()
>> False
>> >>>
>>
>> ..well, I think you see the pattern. Outside of those three
>> ('delimitedtext', 'gpx' and 'gdal'), QLibrary doesn't seem able to
>> load any of the other provider libraries.
>>
>> Now my first guess when QLibrary can't load a library would be that
>> something is wrong with that library. Except of course that when these
>> same commands are issued inside the embedded console under Qgis, these
>> same libs load fine:
>>
>> >>> from PyQt4 import QtCore
>> >>>
>> >>> QtCore.QLibrary(u'/usr/lib/qgis/plugins/libdelimitedtextprovider.so').load()
>> True
>> >>> QtCore.QLibrary(u'/usr/lib/qgis/plugins/libgdalprovider.so').load()
>> True
>> >>> QtCore.QLibrary(u'/usr/lib/qgis/plugins/libgpxprovider.so').load()
>> True
>> >>> QtCore.QLibrary(u'/usr/lib/qgis/plugins/libogrprovider.so').load()
>> True
>> >>>
>> >>> QtCore.QLibrary(u'/usr/lib/qgis/plugins/libspatialiteprovider.so').load()
>> True
>> >>>
>>
>>
>> I've tried making my sys.path identical between the embedded and
>> external python sessions. No effect.
>>
>> I didn't see any obvious systematic problems with the libraries that
>> didn't load (I focussed on libmemoryprovider, because that one is
>> relatively simple), and neither in the ldd nor readelf outputs did
>> anything stand out as an obvious red flag. (I say 'obvious red flag'
>> because I lack the expertise to properly understand even half the
>> things that come out of readelf, and can only look for a limited
>> number of 'telltale signs')
>>
>> So.. what am I missing? Is there some other library that Qgis preloads
>> that makes the loading of the other dynamically linked providers work?
>> And how can I get that to also happen from a regular python script not
>> inside the embedded python console?
>>
>>
>> Kind regards,
>> Nils
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
>
>
> --
> -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
> Gary Sherman
> Chair, QGIS Project Steering Committee
> -Desktop GIS Book:
>  *http://desktopgisbook.com
> -Alaska Novel:
>  *http://alaskana.co
> -Geospatial Consulting & Hosting:
>  *http://geoapt.com
> "We work virtually everywhere"
> -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-



More information about the Qgis-user mailing list