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 py2exe
or 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 ?
Best Answer
I had the same issue when packaging a
fiona
project withpy2exe
. I thinkpy2exe
simply cannot resolve all thefiona
dependencies. But fortunatelyfiona
is well behaved: just add it underpackages
into thepy2exe
script and it will probably also work for you: