where is the Python library for QGIS 2.8 on a mac (10.10)? I cannot find it... sys.path in the QGIS python console gave me some path, but where the interesting part is happening it replaces the folder with dots.

'/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing' and '/Applications/QGIS.app/Contents/MacOS/../Resources/python

I need to set my python path to use the QGis.core library which requires the Path. I got the instruction from this site http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/intro.html but it seems not be up to date anymore...


QGIS for Mac (KyngChaos version) is an application bundle ( directory) and the content of QGIS.app is:

enter image description here

The path of the modules is


The path of the qgis library is


And of the processing module, for example:


If you want to call qgis from outside (in the console, for example), you have two solutions:

1) Define the variables/paths outside Python (Bash)

export PYTHONPATH=/Applications/Qgis.app/Contents/Resources/python
# you can add other modules 
export PYTHONPATH=/Applications/Qgis.app/Contents/Resources/python/plugins:$PYTHONPATH
(export PYTHONPAH=/Users/you/.qgis2/python/plugins:$PYTHONPATH if you want)


from qgis.core import *
QgsApplication.setPrefixPath("/Applications/QGIS.app/Contents/MacOS", True)
# initialize the app
app = QgsApplication([],True)
layer = QgsVectorLayer('/Users/Shared/test.shp', 'test', 'ogr')
print QgsApplication.showSettings()
Application state:
QGIS_PREFIX_PATH env var:       
Prefix:     /Application/QGIS.app/Contents/MacOS
Plugin Path:        /Application/QGIS.app/Contents/MacOS/../PlugIns/qgis
Package Data Path:  /Application/QGIS.app/MacOS/../Resources
Active Theme Name:  
Active Theme Path:  :/images/themes//
Default Theme Path: :/images/themes/default/
SVG Search Paths:    /Application/QGIS.app/Contents/MacOS/../Resources/svg/
User DB Path:   /Application/QGIS.app/Contents/MacOS/../Resources/resources/qgis.db
# import a module
import processing
print processing.__file__

2) Define the paths in Python

import os
import sys

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.