QGIS – Fixing QGIS 2.0 Plugin Error: Unable to Load GdalTools Plugin

errorgdalqgisqgis-plugins

I just used the osgeo4w exe to install QGIS and all the other software included in the basic setup.

When I open QGIS, I get the following error:

Plugin error
Unable to load GdalTools plugin.
The required "osgeo [python-gdal]" module is missing.
Install it and try again.

I opened the Python.exe in the osgeo4w bin folder and am able to import gdal just fine.

Any idea what's wrong here?

Best Answer

GOT IT! My hack DOES work. I was putting it in the wrong place for some reason. So I now have V2 working properly.

I do the following:

  • In Settings->Options->System I check the "Use custom variables" box and add variables to overwrite the GDAL and PYTHON environment variables with the OSGeo paths (I have a separate 64 bit installation of GDAL and it upsets QGIS 32-bit... after all this trouble I haven't yet tried the 64 bit version of QGIS). If you don't have a separate installation of GDAL this is unnecessary.

  • In the same way I prepend the PYTHONPATH variable with the OSGeo path to ..\apps\qgis\python\plugins\GDATools (I'm not sure if this is absolutely necessary but it works so I'll keep doing it for now - if you don't have a separate version of Python, this is certainly unnecessary).

  • I locate the GdalTools.py file (mine is in C:\OSGeo4W\apps\qgis\python\plugins\GdalTools) and edit it by inserting the following two lines just after the import resources_rc line:

    import sys
    sys.path.reverse()

Now my version of QGIS 2.0 (32 bit) starts with no error messages and I have all the GDALTools available. Why this works I have no idea, but without reversing the sys.path variable, QGIS has never worked for me and just setting the paths does not work alone.

Unfortunately whatever version of QGIS you load, they all read the same hidden file for all the paths (as set in step 1) and this means I can't effectively have two versions of QGIS running on the same machine (unless one of them doesn't have GDALTools). So, now I have everything working again, I am loathed to try the 64 bit version (even though it ought to play nicely with my 64 bit installation of GDAL). It would be nice if the QGIS developers could allow you to have different settings for different versions of QGIS. This is especially useful just now when not all the plugins have been migrated over to V2, so running a version QGIS Lisboa is still useful (even if only to get access to a couple of plugins I use a lot like Grids for Atlas).

EDIT
Obviously the sys.path.reverse() code is only temporary and only within the scope of the GDALTools Python script, so it has no lasting effect on your computer.