Select to view content in your preferred language

ogr2ogr raises "DLL not found" error when run from Pro python environment

1491
6
08-26-2022 08:21 AM
DarrenConly
Regular Contributor

Hi All,

Here's what happens:

  1. I open the python command prompt in the default arcgispro-py3 environment, which has gdal installed.
  2. I run ogr2ogr --help to test/confirm that I can use ogr2ogr.
  3. I get, in succession, the 3 error messages below telling me that some dll files are missing:

DarrenConly_1-1661526754586.png

 

DarrenConly_2-1661526788041.png

DarrenConly_4-1661526830314.png

 

Next, I confirmed which version of gdal ships with the Pro environment, and it is gdal 3.4.0:

DarrenConly_5-1661526923330.png

 

Then, as a test, I created a new, non-ESRI conda environment and installed gdal 3.4.0 in it by running conda install gdal=3.4.0, and that worked, i.e., ogr2ogr works fine from a gdal installation in the non-ESRI environment, but I get the "dll not found" errors when running from the ESRI environment.

 

I looked in environment folder that contains ogr2ogr.exe and, lo and behold, the 3 dll files are in the non-ESRI environment version of gdal, but not in the ESRI environment version.

 

Any reason why the ESRI environment doesn't load these DLLs with gdal? Would it mess things up if I simply copied the 3 DLLs over from the non-ESRI installation of gdal over to the ESRI installation?

 

Also, I didn't always have this problem--I believe it has only come up since updating to Pro 3.0.

 

Thanks,

0 Kudos
6 Replies
DanPatterson
MVP Esteemed Contributor

Pro has their own distribution of the packages.  have a look

import osgeo
dir(osgeo)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_gdal', 'config_file',
... SNIP ...
 'this_python_version_will_be_deprecated_in_gdal_version', 'ver_str', 'version_info', 'winreg']

from osgeo import gdal
dir(gdal)
['AbortPendingUploads', 'AllRegister', 'ApplyGeoTransform', 'ApplyVerticalShiftGrid', 'AsyncReader', 'Attribute',
... SNIP ...
'wrapper_GDALVectorTranslateDestDS', 'wrapper_GDALVectorTranslateDestName', 'wrapper_GDALWarpDestDS', 'wrapper_GDALWarpDestName']

... sort of retired...
DarrenConly
Regular Contributor

I see, that might explain why the DLL files aren't in the Pro distribution. Is there some other way to run ogr2ogr commands from within a Pro environment? E.g, does osgeo.gdal have any methods equivalent to running ogr2ogr in the command line?

Ultimately, I want to convert OSM files to SHP files. Ogr2ogr is previously how I've done this.

0 Kudos
DanPatterson
MVP Esteemed Contributor

have a look when you import it and do a dir... I snipped out a huge chunk of the methods, and I don't know which one you are using,


... sort of retired...
0 Kudos
DarrenConly
Regular Contributor

Thanks Dan. A quick scan of the methods from osgeo.gdal didn't reveal anything that obviously seemed like a substitute for ogr2ogr, but as you said there are a lot of them to sift through. I googled around for "arcgis pro gdal" to see if there's a method reference somewhere, but nothing obvious. Will report back if I find anything.

0 Kudos
George_Thompson
Esri Notable Contributor
DarrenConly
Regular Contributor

Interesting to know, but alas does not directly address the issue. As Dan said, Pro uses a different installation of GDAL, which apparently lacks the DLLs needed to run ogr2ogr command line. The link you provided is specific to the gdal python module (not command line ogr2ogr). As Dan and I's thread above describes, my hope is that perhaps there's a way to run ogr2ogr through the python gdal methods, but figuring that out seems time-consuming and will require some sifting through GDAL's API reference.

0 Kudos