I have a short python script, called test:

import fiona
with fiona.open("C:\\Essai_compil", 'r') as l_Obs_shp: 
    for shp in l_Obs_shp:
        print shp['geometry']

I want to compile with py2exeor PyInstaller. OS: Windows7, Python 2.7 (32-bits), I've got erros. With py2exe, the 'log.txt' said :

Traceback (most recent call last):
File "test.py", line 1, in <module>
File "fiona\__init__.pyc", line 78, in <module>
File "fiona\collection.pyc", line 7, in <module>
File "fiona\ogrext.pyc", line 12, in <module>
File "fiona\ogrext.pyc", line 10, in __load
ImportError: DLL load failed: %1 n’est pas une application Win32 valide.
ImportError: DLL load failed: %1 is not a valid Win32 application.

With PyInstaller, log says:

File "ogrext.pyx", line 12 in init fiona.ogrext (src/fiona/ogrext.c:19107)
ImportError: cannot import name ogrinit

Problem are related to fiona module or some ogr stuff... I supposed this is not a 32/64 bits problem; all the modules I've used are 32-bits. More surely a DLL problem... Any ideas ?

  • What Operating System are you using? was this the location of the installers? lfd.uci.edu/~gohlke/pythonlibs/#fiona – Mapperz Oct 3 '13 at 13:35
  • Check out this possibly helpful discussion thread mail-archive.com/cython-dev@codespeak.net/msg02271.html and Google for others. – sgillies Oct 9 '13 at 14:59
  • Some precisions about this error. SPECIFICATIONS: I work with the OSGeo4W'sPython (2.7.4), for 32 bits, because there's numerous geographic modules for Python.Fiona comes from here. I've choose v. 32 bits, for Python 2.7. I've copy the Fiona folder to OSGeo4W folder. PROBLEM: I've try to compile (with Py2exe) a simple module to read a shapefile named test.py (with Fiona) and write shapes coordinates into a .csv named myfile.csv (with csv), here: # test.py module # import fiona import csv shp – user23453 Oct 30 '13 at 10:13

I had the same issue when packaging a fiona project with py2exe. I think py2exe simply cannot resolve all the fiona dependencies. But fortunately fiona is well behaved: just add it under packages into the py2exe script and it will probably also work for you:

opts = {
  'py2exe': {
    'bundle_files': 3

      console=[{"script" : "test.py"}],

Thks geodata, I can compile my script (where I use fiona), with py2exe if I also put into dist folder these libraries:

  • geos.dll
  • spatialindex_c.dll
  • spatialindex.dll

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.