Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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']

share|improve this question
    
gdal tools is no more a plugin, it comes out of the box with the standard qgis installation. –  Giovanni Manghi Aug 20 '12 at 9:33
add comment

2 Answers 2

Alan,

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.

share|improve this answer
add comment

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

Pre-Requisites:

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!

  • share|improve this answer

    We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

    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. May 18 '13 at 7:16
        
    I modified the answer. Thanks for the feedback! –  sundar Jun 3 '13 at 17:39
    add comment

    Your Answer

     
    discard

    By posting your answer, you agree to the privacy policy and terms of service.

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