I have a script written in python 3.5 that uses osgeo gdal (1.11) to extract maps and file info from geotiff files. I would like to compile this code to create a standalone app on windows, and I use pyinstaller (3.2) for this.
The code compiles but does not run, i get the following runtime error:
File "site-packages\osgeo\__init__.py", line 15, in swig_import_helper File "imp.py", line 296, in find_module ImportError: No module named '_gdal'
this is from compiling test1.py, which has a single line:
from osgeo import gdal
pyinstaller.exe --onefile --debug test1.py
and running the resulting test1.exe.
[other tests, not importing gdal, compile and run fine].
It seems there are problems importing osgeo libraries when compiling using pyinstaller and py2exe.
I have seen this question: Working Windows Standalone .EXE From QGIS Python Script Using PyInstaller? and i guess it is related but because it is specific to a qgis environment i do not know how to adapt the solution to my problem.
I have also seen there is a pyinstaller hook for osgeo libraries: https://github.com/pyinstaller/pyinstaller/issues/1522, and https://trac.osgeo.org/gdal/ticket/6364, and i checked i've got this hook in my pyinstaller folder, but it does not solve the import problem for me.
I have also posted to the pyinstaller mailing list but obtained no answer.
How can I obtain a working executable from a standard python script which imports GDAL ?