Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install Python and GDAL (DLL load failed)

Tags:

python

gdal

I am trying to install GDAL and Python on my Windows 7 workstation.

  • Python-version: 2.6.6
  • Gdal 1.8
  • (Visual Visual C++ Studio 2010 Express)

I followed the instructions at http://ucsb.pbworks.com/w/page/1936549/Using-GDAL-with-Python and added PYTHONPATH and the GDAL_DATA to my systems environment variables. Furthermore I modified my PATH variable by adding the GDAL binaries folder.

The GDAL Python bindings I downloaded from: http://vbkto.dyndns.org/sdk/PackageList.aspx?file=release-1600-gdal-1-8-mapserver-5-6.zip

"from osgeo import gdal" causes the following error-message:

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    from osgeo import gdal
  File "C:\Python26\lib\site-packages\osgeo\__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "C:\Python26\lib\site-packages\osgeo\__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

Thanks in advance, Martwig

like image 529
Mario Härtwig Avatar asked May 15 '11 15:05

Mario Härtwig


People also ask

Can you install GDAL with PIP?

You can still install gdal with pip , and here's how to do it. You can also check out the video at the end of this article for a demonstration. If you want to install gdal to a conda (Anaconda) environment you can follow my tutorial for installing gdal with conda .

What is GDAL Python?

GDAL is a translator library for raster and vector geospatial data formats that is released under an MIT style Open Source License by the Open Source Geospatial Foundation.


3 Answers

To successfully load GDAL from python in Windows 7, I follow these steps, which should be quite generic:

  1. Install python of your choosing, I used v2.7.2 x64 downloaded from the official website
  2. Run python from command line to determine the compiler version used to build python (mine shows this message: Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32)
  3. Download the corresponding SDK from this link: http://www.gisinternals.com/release.php. Select the correct package for your python (if using the above configuration, then MSVC2008 x64 release link should be selected).
  4. From the subpage, download the following:
    • GDAL core components
    • Python bindings
  5. Install GDAL core components, add the installation dir to path, and add new environment variable 'GDAL_DATA' pointing to data subdirectory of GDAL installation.
  6. Install python bindings
  7. You should be profiting from them by now :)
like image 73
avee Avatar answered Oct 17 '22 07:10

avee


The step by step procedure is great. But I had the same issue.

This was caused because my PATH variable has other paths where a same named dll was used. If you put the c:\program files\gdal before the other paths in PATH, it works fine!

like image 28
lode Avatar answered Oct 17 '22 07:10

lode


After searching and making many steps from the above answers with no result, i finally got install to Win7 gdal by using the installer from Unofficial Windows Binaries for Python Extension Packages

Just scroll down the page and find GDAL section and get your version installer.

like image 35
Stayros Anastasiadis Avatar answered Oct 17 '22 07:10

Stayros Anastasiadis