Opened 14 years ago
Closed 14 years ago
#3426 closed defect (fixed)
"import gdal" returns "ImportError: DLL load failed" in Python on Vista 32 bits
Reported by: | nono | Owned by: | hobu |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | PythonBindings | Version: | 1.6.1 |
Severity: | normal | Keywords: | |
Cc: |
Description
Hello,
I tried to install GDAL with Python bindings, and I run into an error in Python when importing the module.
I work on Windows Vista 32 bits, and I followed the instructions: http://trac.osgeo.org/gdal/wiki/GdalOgrInPython First, I installed the GDAL Windows Binaries, and accordingly updated the PATH and created the GDAL_DATA environment variables. Then, I used the Windows installer GDAL-1.6.1.win32-py2.6.exe to set up Python bindings.
And when I try "import gdal", "import osgeo.gdal" or "from osgeo import gdal" from Python, I get the following error message:
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\osgeo\gdal.py", line 7, in <module>
import _gdal
ImportError: DLL load failed: Le module spécifié est introuvable.
I checked that the library _gdal.pyd is in the folder C:\Python26\Lib\site-packages\osgeo as it should, and it's there. I tried to add the path to that folder within Python in sys.path, but it does not solve the bug. I read in some discussion that Crystal Report should be uninstalled for some incompatibility reason, which I did without success...
Does anybody has an idea?
Regards,
Bruno G.
Change History (6)
comment:1 by , 14 years ago
Component: | default → PythonBindings |
---|---|
Owner: | changed from | to
comment:2 by , 14 years ago
Version: | unspecified → 1.6.1 |
---|
PS [reply to e-mail]: I'm not Kredik. Has he had exactly the same problem?
comment:3 by , 14 years ago
That conversation seemed related, I'm not sure if it will be helpful:
<kredik> hi all, I am trying to build gdal with python support on windows ( vc2003 ). What version of python is supported ? 3.1.1 or 2.6.4 ? What version of swig should i use ? * ue has quit (Ping timeout: 276 seconds) * ue (~ue@89.28.120.79) has joined #gdal <FrankW> kredik: I think 1.3.39 is preferred. <FrankW> That's swig. <FrankW> I would suggest Python 2.6.4, though in theory trunk and 1.7 support 3.x as well. <kredik> FrankW : few months ago I has successfully build gdal1.6.0 with python support. But It seems that with 1.7 things have changed. There is no more 'pymod directory. <FrankW> The pymod directory contained the old bindings. They are removed from 1.7. <FrankW> Now you build python support in the gdal/swig/python directory. <FrankW> http://trac.osgeo.org/gdal/wiki/GdalOgrInPython should have some details on building on windows half way down. <sigq> Title: GdalOgrInPython - GDAL - Trac (at trac.osgeo.org) <kredik> I can build something in swig/python with : <kredik> python.exe setup.py build <kredik> python.exe setup.py install <kredik> I have added the bin path of my gdal install to the PATH, but I cant load the module from python <FrankW> Do you get a specific error? <kredik> >>> from osgeo import gdal <kredik> Traceback (most recent call last): <kredik> File "<stdin>", line 1, in <module> <kredik> File "E:\DEV\GDAL_BUILD\3rdParty\Python26\lib\site-packages\osgeo\__init__.py", line 21, in <module> <kredik> _gdal = swig_import_helper() <kredik> File "E:\DEV\GDAL_BUILD\3rdParty\Python26\lib\site-packages\osgeo\__init__.py", line 17, in swig_import_helper <kredik> _mod = imp.load_module('_gdal', fp, pathname, description) <kredik> ImportError: DLL load failed: Le module spÚcifiÚ est introuvable. <kredik> >>> <kredik> my dll is named gdal17.dll in the bin dir <FrankW> Can you try, temporarily, copying gdal17.dll into c:\windows\system32? <kredik> I got the same error. <FrankW> funky <FrankW> I'm rather at a loss I'm afraid. Perhaps hobu can help? <kredik> do you know what is expected to be under the "site-packages\osgeo" directory ? <kredik> FrankW: after a clean & rebuild it works now. thanks for your help.
comment:4 by , 14 years ago
Well I used the Windows installer of the version 1.6: http://pypi.python.org/packages/2.6/G/GDAL/GDAL-1.6.1.win32-py2.6.exe
When I download the source: http://pypi.python.org/packages/source/G/GDAL/GDAL-1.7.0.tar.gz and try to build it ("python.exe setup.py build"), I get an error from
running build running build_py running build_ext building 'osgeo._gdal' extension C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I../../port -I../../gcore -I../../alg -I../../ogr/ -IC:\Python26\include -IC:\Python26\PC -IC:\Python26\lib\site-packages\numpy\core\include /Tpextensions/gdal_wrap.cpp /Fobuild\temp.win32-2.6\Release\extensions/gdal_wrap.obj gdal_wrap.cpp C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc extensions/gdal_wrap.cpp(2813) : fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2
comment:5 by , 14 years ago
I meant, I get an error from VC compiler:
running build running build_py running build_ext building 'osgeo._gdal' extension C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I../../port -I../../gcore -I../../alg -I../../ogr/ -IC:\Python26\include -IC:\Python26\PC -IC:\Python26\lib\site-packages\numpy\core\include /Tpextensions/gdal_wrap.cpp /Fobuild\temp.win32-2.6\Release\extensions/gdal_wrap.obj gdal_wrap.cpp C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc extensions/gdal_wrap.cpp(2813) : fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2 C:\Users\Bruno\Desktop\GDAL-1.7.0>python.exe setup.py build running build running build_py running build_ext building 'osgeo._gdal' extension C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I../../port -I../../gcore -I../../alg -I../../ogr/ -IC:\Python26\include -IC:\Python26\PC -IC:\Python26\lib\site-packages\numpy\core\include /Tpextensions/gdal_wrap.cpp /Fobuild\temp.win32-2.6\Release\extensions/gdal_wrap.obj gdal_wrap.cpp C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc extensions/gdal_wrap.cpp(2813) : fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2
comment:6 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I managed to solve the problem, though I don't really understand how! After a couple of uninstall-reinstall, and installs of previous versions (through FWTools, OSGeo4W), it just started working.
Unfortunately, I ran on another bug: Python crashes whenever I try to read a raster file (using ReadAsArray, or ReadRaster). Someone had a similar problem: http://n2.nabble.com/Gdal-Python-Win7-crash-with-ReadAsArray-td4398401.html
But I'll open a new ticket.
You wouldn't happen to be Kredik from IRC who had a similar problem this morning would you? If so, please close the ticket noting your solution.