I'm really getting mad with this. ArcGIS sometimes can be so just...irritating! Forgive me if this question is by any means duplicating this one or similar ones, but I really can't find my way out of this problem.
I have a x64 Windows Server 2012 machine (pretty cutting-edge, isn't it?) and a 32-bit ArcMap 10.1 installation on it, as well as a 64-bit ArcGIS Server installation. I came up with having two different Python 2.7 installations on my machine, both placed by ArcGIS:
C:\Python27\ArcGIS10.1\ #32 bit Python 2.7
C:\Python27\ArcGISx6410.1\ #64 bit Python 2.7
Now, what I want to do is to make an ArcMap tool which peforms calls to GDAL 1.9 Python binding library. My tool starts with a standard import of the gdal bindings:
import gdal
from gdalconst import *
[...]
I therefore installed (using gisinternals.com/sdk msi installers) BOTH 32 AND 64 bit GDAL core binaries and binding libraries, so I have:
#GDAL core binaries
C:\Program Files\GDAL #64 bit
C:\Program Files (x86)\GDAL #32 bit
#GDAL bindings
C:\Python27\ArcGIS10.1\Lib\site-packages\osgeo #32 bit
C:\Python27\ArcGISx6410.1\Lib\site-packages\osgeo #64 bit
#PATH environment variable
echo %PATH%
C:\Program Files (x86)\GDAL;[...]
If I try to import the gdal bindings via both the Python interpreters, I get the followings:
C:\>C:\Python27\ArcGIS10.1\python.exe -m gdal
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.1\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\ArcGIS10.1\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\ArcGIS10.1\lib\site-packages\gdal.py", line 2, in
from osgeo.gdal import deprecation_warn
File "C:\Python27\ArcGIS10.1\lib\site-packages\osgeo\__init__.py", line 29, in
_gdal = swig_import_helper()
File "C:\Python27\ArcGIS10.1\lib\site-packages\osgeo\__init__.py", line 25, in
swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: DLL load failed: %1 is not a valid Win32 application.
C:\>C:\Python27\ArcGISx6410.1\python.exe -m gdal
Traceback (most recent call last):
File "C:\Python27\ArcGISx6410.1\lib\runpy.py", line 162, in _run_module_as_mai
n
"__main__", fname, loader, pkg_name)
File "C:\Python27\ArcGISx6410.1\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\ArcGISx6410.1\lib\site-packages\gdal.py", line 2, in >
from osgeo.gdal import deprecation_warn
File "C:\Python27\ArcGISx6410.1\lib\site-packages\osgeo\__init__.py", line 21,
in
_gdal = swig_import_helper()
File "C:\Python27\ArcGISx6410.1\lib\site-packages\osgeo\__init__.py", line 17,
in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: DLL load failed: %1 is not a valid Win32 application.
and the very same error is given by the ArcMap Python shell when I try to run the tool:
Traceback (most recent call last):
File "C:\processors\URBAN_CLASS\URBAN_CLASS.py", line 2, in
import GLCM_wrapper.GLCM_wrapper
File "C:\processors\URBAN_CLASS\GLCM_wrapper\GLCM_wrapper.py", line 2, in
import gdal
File "C:\Python27\ArcGIS10.1\lib\site-packages\gdal.py", line 2, in
from osgeo.gdal import deprecation_warn
File "C:\Python27\ArcGIS10.1\lib\site-packages\osgeo\__init__.py", line 29, in
_gdal = swig_import_helper()
File "C:\Python27\ArcGIS10.1\lib\site-packages\osgeo\__init__.py", line 25, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: DLL load failed: %1 is not a valid Win32 application.
In addition, I tried to have the sys.path printed out from the ArcMap Python shell:
['C:\\processors\\URBAN_CLASS',
u'c:\\program files (x86)\\arcgis\\desktop10.1\\arcpy',
'C:\\Windows\\SYSTEM32\\python27.zip',
'C:\\Python27\\ArcGIS10.1\\Lib',
'C:\\Python27\\ArcGIS10.1\\DLLs',
'C:\\Python27\\ArcGIS10.1\\Lib\\lib-tk',
'C:\\Windows\\system32',
'C:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\bin',
'C:\\Python27\\ArcGIS10.1',
'C:\\Python27\\ArcGIS10.1\\lib\\site-packages',
'C:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\arcpy',
'C:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\ArcToolbox\\Scripts']
Any hint/idea on how to make my tool correctly import the gdal bindings? I'm completely stuck!
No comments:
Post a Comment