[Qgis-user] MACOS paths for pyqgis

William Kyngesburye woklist at kyngchaos.com
Sat Jul 7 08:09:58 PDT 2012


On Jul 7, 2012, at 2:54 AM, Phil Cummins wrote:

> 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.
> 
You don't need the disk name at the beginning of the pythonpath, just:

/Applications/QGIS.app/Contents/Resources/python


> 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?
> 
I don't think you need to set the prefix path, it's set when QGIS starts.  But if you are running a python script without QGIS running, I guess it would need to be set... I think it's the MacOS subdir.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"This is a question about the past, is it? ... How can I tell that the past isn't a fiction designed to account for the discrepancy between my immediate physical sensations and my state of mind?"

- The Ruler of the Universe





More information about the Qgis-user mailing list