There has been a tons of questions on that but none of them solved my problem.
I have a machine with:
- Windows 7 x64
- Python 3.4.3 x64
- gdal installed:
gdalinfo --version --> GDAL 1.11.4, released 2016/01/25; gdal was installed from a wheelGDAL-1.11.4-cp34-none-win_amd64.whlfrom here
The GDAL is installed into C:\Python34\Lib\site-packages\osgeo. There I have a bunch of .exe files for gdal and ogr and .pyd files.
- fiona installed: was installed from a wheel
Fiona-1.6.3-cp34-none-win_amd64.whl, from the same website.
I am able to run this code and it executes successfully:
import gdal
import ogr
from gdalconst import *
shp = r"C:\Data\GIS\PTS.shp"
driver = ogr.GetDriverByName('ESRI Shapefile')
dataset = driver.Open(shp)
layer = dataset.GetLayer()
layer.GetFeatureCount()
schema = layer.schema
fields = [field.GetName() for field in schema]
feature = layer.GetNextFeature()
I am also able to get OGR formats: ogrinfo --formats prints a bunch of them in the Windows cmd (with no FileGDB there though).
I am able to run this code and it executes successfully:
import fiona
with fiona.drivers():
with fiona.open(path=r'C:\Data\GIS\TemplateData.gdb', driver='OpenFileGDB') as source:
print(source.meta)
However, this code won't run:
with fiona.drivers():
with fiona.open(path=r'C:\Data\GIS\TemplateData.gdb', driver='FileGDB') as source:
print(source.meta)
Because I don't have Esri File GDB compiled libraries which are required.
I have downloaded and unpacked FileGDB_API_VS2012_1_3.zip from the Esri downloads page. As I understood, there is no need to compile anything as the .dll is already there.
What is the correct procedure to register the dll of the Esri File GDB API to be able to use them in fiona in my environment?
UPDATE: (based on Luke's answer)
I have downloaded the File Geodatabase API 1.4 version for Windows (Visual Studio 2010) from the Esri downloads page. I copied the FileGDB_API_VS2010_1_4\bin64\FileGDBAPI.dll to the C:\Python34\Lib\site-packages\osgeo. Now I have two files in here, ogr_FileGDB.dll and FileGDBAPI.dll.
I have created a Windows variable GDAL_DRIVER_PATH : C:\Python34\Lib\site-packages\osgeo\gdalplugins. In the PATH variable, I don't have anything Python specific except the C:\Python34\Lib\site-packages\osgeo.
Now when running the ogrinfo --formats I get -> "FileGDB" (read/write) and am able to use the Python code for working with the FileGDB driver.
[python install dir]\Lib\site-packages\osgeodir as I specified in my answer, not the gdalplugins dir you mention in your edit. Only driver plugins go in that directory, not 3rd party dlls. – user2856 May 13 '16 at 05:38GDAL_DRIVER_PATHenv var controls where gdal/ogr looks for driver plugins. The API dll needs to be where Windows will look for it when the driver tries to load it. i.e either be in the same directory as the main gdal11.dll or in one of the directories in yourPATHenv. var. – user2856 May 13 '16 at 06:04FileGDB_API_VS2010_1_4.zipfrom ESRI website. Instead, you can download it directly from their github repo. – François Leblanc Mar 16 '18 at 15:40import fiona:ERROR 1: Can't load requested DLL: c:\Users\aboufira\AppData\Local\Continuum\miniconda3\envs\11203028_PHP\Lib\site-packages\osgeo\gdalplugins\ogr_FileGDB.dll 126: The specified module could not be found.– user32882 Jul 05 '19 at 14:24