When I run my script outside ArcGIS it works because during execution script uses a GDAL and OGR modules from osgeo. When I use script as a tool in ArcGIS it does not work. In PySripter I can import all modules and it work. In Python Window in ArcGIS I cannot import because I get this error:
Parsing error SyntaxError: invalid syntax (line 2) import ogr Runtime error Traceback (most recent call last): File "", line 1, in File "C:\Python27\ArcGIS10.1\lib\site-packages\osgeo\ogr.py", line 26, in _ogr = swig_import_helper() File "C:\Python27\ArcGIS10.1\lib\site-packages\osgeo\ogr.py", line 22, in swig_import_helper _mod = imp.load_module('_ogr', fp, pathname, description) ImportError: DLL load failed:
In the case when I import gdal in ArcGIS Python Window I do not get this error. How to force arcgis to import ogr and use it in ModelBuilder or Script?? I check a lot of solutions includin reinstallation, changing and adding environment variables. I checked :
and I still do not have a good solution. Any idea?
UPDATE: I also try use direct importing in my script: import imp ogr = imp.load_source('ogr', 'c:\Python27\Lib\site-packages\osgeo\ogr.py' and I get the same error. If I use this method in standalone script it works.