[Qgis-user] MACOS paths for pyqgis

Phil Cummins phil.cummins at gmail.com
Sat Jul 7 00:54:35 PDT 2012


Hi,

I am using QGIS 1.8.0 in Mac OS Lion. I have installed the Openlayers plugin and made a map I am happy with. But now I have to make about a dozen similar maps so I'd like to automate the process. I am used to writing Python scripts, but am new to pyqgis.

I have added /Volumes/Macintosh\ HD/Applications/QGIS.app/Contents/Resources/python to my PYTHONPATH, and set LD_LIBRARY_PATH to /Volumes/Macintosh\ HD/Applications/QGIS.app/Contents/MacOS/lib. So I can now import qgis.core and qgis.utils with no problem. But I can't seem to access any plugins. E.g.

In [70]: qgis.utils.loadPlugin('openlayers')
Out[70]: False

and:
In [71]: qgis.utils.plugins
Out[71]: {}

The open layers plugin is installed in ~/.qgis/python/plugins, and other plugins appear to be in /Volumes/Macintosh\ HD/Applications/QGIS.app/Contents/PlugIns.

There appears to be a qgis.utils.plugin_paths, and a qgis.utils.pluginDirectory, as well as things like findPlugins() and loadPlugin(). Can anyone please tell me if these are what I need to use, and if so does anyone know the correct calling sequence to get my plugin loaded properly?

Also, I have seen that pyqgis scripts should use QgsApplication.setPrefixPath to set the QGIS 'installation directory', and then call QgsApplication.initQgis(). But what is the 'installation directory': QGIS.app, QGIS.app/Contents, QGIS.app/Contents/MacOS? Perhaps someone could please tell me what subdirectories the installation directory should contain?

Many thanks,

- Phil






More information about the Qgis-user mailing list