Trying to import gdal for Python 2.7.3 on Windows XP:
>>> import gdal
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\gdal.py", line 2, in <module>
from osgeo.gdal import deprecation_warn
File "C:\Python27\lib\site-packages\osgeo\__init__.py", line 21, in <mo
_gdal = swig_import_helper()
File "C:\Python27\lib\site-packages\osgeo\__init__.py", line 17, in swit_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: DLL load failed: The specified procedure could not be found.
Following suggestions from Installing GDAL with Python on windows? and elsewhere, here's what I've done so far:
- removed all versions of python and started with a clean install of 2.7.3
- installed gdal with the OSGeo4W installer
- installed the native Win gdal binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/
- added
C:\OSGeo4W\bin;
first in myPath
variable - tried
from osgeo import gdal
- launched python from within the OSGeo4W Shell
- run the procedure outlined in http://cartometric.com/blog/2011/10/17/install-gdal-on-windows/
The result is the same. Any other ideas about how to troubleshoot this?
4 Answers 4
Condensed procedure outlined in http://cartometric.com/blog/2011/10/17/install-gdal-on-windows/ for Windows 7, 32 Bits, to install GDAL PYTHON:
1) Install Python.
I installed Python 2.7.9 from https://www.python.org/
2) Install the GDAL binaries published by Tamas Szekeres.
First, I launched IDLE (Python GUI) noting the following values: "MSC v.1500" and "on win32":
enter image description here
In this link: http://www.gisinternals.com/release.php
Click in the magenta link of the below image:
enter image description here
Click in the magenta links of the below image for download and install gdal-111-1500-core.msi and GDAL-1.11.1.win32-py2.7.msi:
enter image description here
3) Append your environment Path variable
enter image description here
enter image description here
After click in Edit and search for Path, add:
;C:\Program Files\GDAL
DON'T FORGET the ; character before C:\Prog... and click OK three times:
enter image description here
4) Add the GDAL_DATA environment variable (one click in New for each variable: gdal-data and gdalplugins)
DON'T FORGET click OK three times:
enter image description here
enter image description here
5) Finally, perform a quick test to make sure everything worked.
Launch IDLE (Python GUI) and type from osgeo import gdal [Enter]:
enter image description here
I didn't get gdal ImportError in python on my Windows 7 system.
Note: import gdal is deprecated.
-
1I have tried with all above explained methods but it show error like this: ImportError: DLL load failed: The specified procedure could not be found.Shiuli Pervin– Shiuli Pervin2016年09月09日 08:24:55 +00:00Commented Sep 9, 2016 at 8:24
-
I know that this method works for 7 and 8 Windows systems and python 2.7 with 32 bits. If you have different conditions you should carefully read in each link those that match in your own system.xunilk– xunilk2016年09月09日 08:37:07 +00:00Commented Sep 9, 2016 at 8:37
-
Thanks!I have recently windows 10 and I am screwed up. I installed in my office several computers it worked perfectly but not at home it is not working at all. I am hang up for several hours. Do you have any idea about it?Shiuli Pervin– Shiuli Pervin2016年09月09日 09:16:33 +00:00Commented Sep 9, 2016 at 9:16
-
1Same boat as you, @ShiuliPervin. It's a joke... so difficult to install this. I have literally spent all day trying to get gdal installed. Ridiculous! Apparently, though, you can do this with scipi hydro.washington.edu/~jhamman/hydro-logic/blog/2013/10/12/… as well as python-netcdf4pookie– pookie2016年11月05日 21:44:30 +00:00Commented Nov 5, 2016 at 21:44
-
I meant netcdf4-python: netcdf4-python github.com/Unidata/netcdf4-pythonpookie– pookie2016年11月05日 21:52:29 +00:00Commented Nov 5, 2016 at 21:52
I recommend to place the path to GDAL in the PATH variable BEFORE(!!) the python path. In this way you avoid the fact that python can not find the necessary gdal.dlls
Similarly, I placed
C:\Program Files (x86)\GDAL;
at the very first in the Path of System Variables. Issue solved after 1 day of searching the web. Using Python 2.7.10, 32 bit, Windows 8.
-
This solved my problem completely! I had Arc Desktop installed first and then installed gdal without an issue once I did this.MoreMeowbell– MoreMeowbell2020年03月21日 04:14:51 +00:00Commented Mar 21, 2020 at 4:14
-
This was an important step in the solution for me. For the rest, check the RobertH community wiki and my comments below it: gis.stackexchange.com/questions/2276/…Güray Hatipoğlu– Güray Hatipoğlu2022年03月03日 12:28:21 +00:00Commented Mar 3, 2022 at 12:28
If installing via whl you must install the visual-c redistribute to get gdal to work!
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
from osgeo
.