I have qgis 1.8.0 on osx mountain lion and am installing the gdaltools 1.2.29. I have run into a problem that a number of people are seeing. The plugin cannot find my gdal python (see below).

Anyway, I can fix the problem hackily (if that is a word) by symlinking

  cd /Library/Python/2.7
  sudo mv site-packages/ site-packages-old
  sudo ln -s /Library/Frameworks/GDAL.framework/Versions/1.9/Python/2.7/site-packages /Library/Python/2.7

So that fixes the prob because the python path list that the plugin knows about includes /Library/Python/2.7/site-packages But the real solution is to add a path to the list of paths that the python plugin[s] know about. How do you do that?

----start of error message----

Couldn't load plugin GdalTools due an error when calling its classFactory() method

Traceback (most recent call last): File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 164, in startPlugin plugins[packageName] = package.classFactory(iface) File "/Users/aberezin/.qgis//python/plugins/GdalTools/init.py", line 32, in classFactory from GdalTools import GdalTools File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/Users/aberezin/.qgis//python/plugins/GdalTools/GdalTools.py", line 39, in raise ImportError( error_str ) ImportError: No module named osgeo [python-gdal]

Python version: 2.7.2 (default, Jun 20 2012, 16:23:33) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]

QGIS version: 1.8.0-Lisboa Lisboa,

Python path: ['/Applications/QGIS.app/Contents/MacOS/../Resources/python', '/Users/aberezin/.qgis//python', '/Users/aberezin/.qgis//python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']

  • gdal tools is no more a plugin, it comes out of the box with the standard qgis installation.
    – gioman
    Commented Aug 20, 2012 at 9:33

2 Answers 2



The path to gdal's Python bindings is missing because Apple seems to remove anything in the system site-packages folder during upgrade to Mt. Lion (thank-you-very-much Apple).

There is a thread in the QGIS User mailing list about this, and gdal in particular. You basically have to reinstall all previously installed Python packages, or possibly copy them over from a pre-Mt. Lion upgrade backup.

However, first you must undo what you did when creating your symbolic link to the gdal framework subdirectory: remove the link and rename site-packages-old back to site-packages. You definitely do not want to rename the site-packages folder of your Python installation, or point it to a specific library's install.

After you have your gdal/osgeo Python support reinstalled, GdalTools, which is a separate core plugin that is part of QGIS, as Giovanni noted, should work fine.


Here is how I got this working on my machine :

Here is the context:

You are running a Mac with Mountain Lion You need to install GDAL with its python bindings


I use the MacPorts package managers for mac, and PythonBrew for managing my python installation and virtual environment management, and based on my experiences, I urge you to do the same :)

  • Install mac ports and pythonbrew
  • Using pythonbrew, install the python version > 3.2 for the latest python GDAL bindings to work (yup, you heard it right. you need python > 3.2 for you to use the python bindings). ‘switch’ to that version of python.
  • using macports, install gdal, by doing : port install gdal
  • Setup a virtual environment using pythonbrew (see the the "usage" section of the pythonbrew home page above), and switch to that virtual env.
  • Download the gdal package by doing : pip install —no-install GDAL This will error out : don’t worry, we did this to grab the source.
  • cd ~/.pythonbrew/venvs/PYTHON_VERSION/VIRTUALENV_NAME/build/GDAL
  • Edit setup.cfg, and change gdal_conf to point to /opt/local/bin/gdal-config (note that this does not have a ‘_’, but a hyphen)
  • From the same directory, do a : python setup.py build_ext —include-dirs=/opt/local/include/
  • This should compile without any errors (some warnings, but no actual errors)
  • We aren’t done yet : to complete installation, do a ‘pip install —no-download GDAL’

    To test your installation, from the python interpreter, do a : ‘from osgeo import gdal’ and check that no errors show up.

    Hope that helps!

  • 1
    • 1
      Welcome to GIS SE! Thanks for your answer. Could you post the important bits along with your answer? Here at GIS SE, we try to make the answers stand on their own. Your answer might be helpful but it will be useless if the link it points to suddenly dies. It would be great if you could post a summary here.
      – R.K.
      Commented May 18, 2013 at 7:16

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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