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 wheel GDAL-1.11.4-cp34-none-win_amd64.whl from 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()
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:

However, this code won't run:

with fiona.drivers():
    with fiona.open(path=r'C:\Data\GIS\TemplateData.gdb', driver='FileGDB') as source:

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.

  • The 1.4 File Geodatabase API has been released for a lonnng time now. There really is no reason to use 1.3. – Vince May 12 '16 at 11:12
  • @Luke, thanks, but I need write access to the gdb. Afaik, you can only read with OpenFileGDB... Any specific links or doc page how to achieve that with the compilation and how to point out to the dll (via Windows variables etc)? Would be very helpful. – Alex Tereshenkov May 12 '16 at 12:16
  • @Vince, I don't mind using 1.4 or any other version that would allow me editing the file gdb :) I lack the docs page / spec with clear instructions how to be able to do that. – Alex Tereshenkov May 12 '16 at 12:16
  • @AlexTereshenkov As you're using 64bit python, copy the Esri bin64\FileGDBAPI.dll to the [python install dir]\Lib\site-packages\osgeo dir 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 5:38
  • 1
    @AlexTereshenkov, ogr_FileGDB.dll is the FileGDB driver (not OpenFileGDB which is built into gdal/ogr). This dll is compiled from the GDAL/OGR driver code. It needs to be in the directory specified by the GDAL_DRIVER_PATH env var. – user2856 May 13 '16 at 6:03

The Gohlke GDAL/OGR wheel includes the FileGDB driver compiled as a plugin.

To get the FileGDB driver working:

  1. Copy the Esri bin64\FileGDB.dll to [python install/virtualenv dir]\Lib\site-packages\osgeo (use bin\FileGDB.dll if using 32bit python). Do not copy the FileGDB.dll to the gdalplugins directory.
  2. Set GDAL_DRIVER_PATH environment variable, either:
    • manually; or
    • edit [python install/virtualenv dir]\Lib\site-packages\osgeo\__init__.py and uncomment line 10.
      # uncomment the next line to enable plugins
      os.environ['GDAL_DRIVER_PATH'] = os.path.join(os.path.dirname(__file__), 'gdalplugins')

Opening a GDB with the FileGDB driver should now work.

>>> import fiona
>>> with fiona.drivers():
...     with fiona.open(path=r'C:\Temp\Default.gdb', driver='FileGDB') as source:
...         print(source.meta)
{'crs': {'init': u'epsg:4326'}, 'driver': 'FileGDB', 'crs_wkt': u'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01
74532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]', 'schema': {'geometry': 'MultiPolygon', 'properties': OrderedDict([(u'SHAPE_Length', 'float'), (u'SHAPE_Area', 'float')])}}


Using Python 2.7 I could only get FileGDB plugin to work with the FileGDB API v1.3 (MSVC 2008). as v.1.4 segfaults python. I assume this is because python and the GDAL and Fiona libraries provided by Gohlke are compiled with MSVC 2008 and v. 1.4 is compiled with MSVC 2010 (and later).

The FileGDB API v1.4 works fine with Python 3.4 and the GDAL and Fiona libraries provided by Gohlke which are compiled with MSVC 2010.

|improve this answer|||||
  • I'd to copy bin64\FileGDBAPI.dll from FileGDB_API_1_5_1-VS2010.zip located at github.com/Esri/file-geodatabase-api/tree/master/… at step 1 to make it work (in Python 3.5 64bit) – Mattijn Jan 30 '18 at 16:28
  • My gdal was automatically installed by geopandas using the miniconda command line conda install geopandas. In __init__.py line 10 is already uncommented, so I don't think it is the line you are referring to. Also there is no gdalplugins file – user32882 Jul 5 '19 at 12:25
  • @user32882 These instructions are not for conda installed gdal... – user2856 Jul 5 '19 at 13:34
  • How can I set it up for conda? Is this possible? – user32882 Jul 5 '19 at 14:07

The key information is here:

I am also able to get OGR formats: ogrinfo --formats prints a bunch of them in the Windows cmd (with no FileGDB there though).

This tells me that your GDAL_DRIVER_PATH environment variable is not set. See the instructions at https://trac.osgeo.org/gdal/wiki/FileGDB#Testingthedriver. Once "FileGDB" shows in ogrinfo --formats (or fio env --formats), you'll be good to go.

|improve this answer|||||
  • thanks. Surprised you have time to answer questions on GIS.SE - you are probably super busy with fiona, shapely and other stuff. Very cool things you wrote, kudos. I am aware that I don't have the FileGDB driver hence asking how to do that. I've seen the page you refer to, it says one needs to Compile GDAL with the FGDB section commented . I don't have the GDAL source; I've just installed it from the wheel, so I guess those steps are not applicable in my case. Where should I go from here? – Alex Tereshenkov May 12 '16 at 15:34
  • 1
    The GDAL_DRIVER_PATH variable is the key. Read trac.osgeo.org/gdal/wiki/ConfigOptions#GDAL_DRIVER_PATH and if that doesn't set you on the right path, see the thread at lists.osgeo.org/pipermail/gdal-dev/2014-May/039066.html. – sgillies May 12 '16 at 19:17
  • A bit misleading steps as I didn't need to compile anything - the wheels I've installed already had everything I needed, it was just about pasting the files in the right folder. But thanks a ton for the useful info anyways, good to know for some other use cases. – Alex Tereshenkov May 13 '16 at 5:56
  • This is absolutely the correct answer. No need to change the installation around, just set the right paths! – Benjamin Mar 14 '19 at 18:40

Copying files FileGDBAPI.dll into folder C:\Program Files\QGIS 2.18\bin and ogr_FileGDB.dll into folder C:\Program Files\QGIS 2.18\bin\gdalplugins does the trick for me. Here's a document that explains their use.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.