2

I have QGIS installed (on Windows) and can import this line from the QGIS Python console:

from osgeo import gdal

When I try the import in a python file it doesn't work

Traceback (most recent call last):
  File "C:/Users/xxx/loader.py", line 6, in <module>
    from osgeo import gdal
ImportError: No module named osgeo

How can I use the osgeo lib outside from qgis?

1

i don't recall all the steps i used, but with the anaconda distro, i placed a text file (something like qgislibs.pth) within my anaconda directory (or you default python install) - within the text file, include the path to your osgeo4w site packages - probably like C:\OSGeo4W64\apps\Python27\Lib\site-packages\

i think i also had to include a path in the system environment variables to point to the gdal binaries - something like C:\OSGeo4W\bin

i doubt that's fool proof everywhere, but it's working for me.

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.