Friday 20 January 2017

geotiff tiff - working standalone app .exe from python3 script that imports osgeo gdal?


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

with


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 ?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...