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

有帮助吗?

解决方案

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 :)

其他提示

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!

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.

solution for python 3.4, v.1600, Windows 10

make sure what your python version is

python -v
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32

so here you see that it's v.1600 and 32 bit. Then go here

http://www.gisinternals.com/query.html?content=filelist&file=release-1600-gdal-mapserver.zip

and download:

  1. gdal-201-1600-core.msi
  2. GDAL-2.1.0.win32-py3.4.msi
  3. Install these msi files

a. then make sure you DON'T GET OSGEO4W installed anywhere (just remove the folder completely if you got it installed).

b. go and edit your environment vars and include in PATH: C:\Program Files (x86)\GDAL; (include in the beginning!)

c. restart your python / virtualenv and IDE.

You should get everything working at this point

there are also bindings for python 2.7, 3.3, 3.1, other releases http://www.gisinternals.com/development.php

I successfully installed gdal on 32 bit Windows from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal. I solved the "side by side" DLL error by installing this Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package MFC Security Update.

Try this:

  • Add the GDAL core folder path to your PYTHONPATH variable
  • If using PyDev in Eclipse, force the global PATH variable to be include it using the PyDev interpreters section. You can also set PYTHONPATH here.

I got rid of this error after doing this. Funny thing was, calling that line that throws the import exception in a Python interactive shell worked before. Maybe we're all using PyDev.

I found that I needed to add the environment variables PATH, GDAL_DATA and GDAL_DRIVER_PATH (all three of them) to System variables NOT user variables for "your username".

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top