2

I am using PyInstaller to generate an executable from a python script. This is what I did:

sudo python2 -m PyInstaller ptemplatized.spec 

It builds successfully the .exe but when I execute it I get the following error:

[19878] LOADER: Running pyi_rth_mpldata.py
[19878] LOADER: Running pyi_rth_multiprocessing.py
[19878] LOADER: Running pyi_rth__tkinter.py
[19878] LOADER: Running pyi_rth_pkgres.py
[19878] LOADER: Running physiocap_templatized.py
Traceback (most recent call last):
  File "/home/abderrahmen/Bureau/PC/pour/physiocap_templatized.py", line 38, in <module>
    import geopandas
  File "/tmp/pip-build-2qvLhV/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
  File "/usr/local/lib/python2.7/dist-packages/geopandas/__init__.py", line 5, in <module>
    from geopandas.io.file import read_file
  File "/tmp/pip-build-2qvLhV/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
  File "/usr/local/lib/python2.7/dist-packages/geopandas/io/file.py", line 4, in <module>
    import fiona
  File "/tmp/pip-build-2qvLhV/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
  File "/home/hadoop/.local/lib/python2.7/site-packages/fiona/__init__.py", line 83, in <module>
    from fiona.collection import BytesCollection, Collection
  File "/tmp/pip-build-2qvLhV/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 395, in load_module
  File "/home/hadoop/.local/lib/python2.7/site-packages/fiona/collection.py", line 9, in <module>
    from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
  File "/tmp/pip-build-2qvLhV/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 684, in load_module
  File "fiona/ogrext.pyx", line 1, in init fiona.ogrext
ImportError: No module named _shim
[19878] Failed to execute script ptemplatized

I tried looking for the module but it seems to not exist. Thank you.


EDIT:

So I got this answer on another website:

Fiona has extension modules and some fairly complicated logic in its setup script to manage them with respect to different versions of the GDAL library. This is why python setup.py build (as reported in another issue) won't work, you have to do python setup.py build_ext build. I think you'll need to find a way for pyinstaller to run the build_ext command defined in fiona's setup.py and then you'll be all set.

Can anyone tell me how can that be done in my case?


EDIT2:

I countred this error by installing an ancient gdal version using a tuto. Now my Pyinstaller creates the .exe without errors bur when I execute it on another Machine I get the same error. Isn't the goal from using PyInstaller is to execute an .exe file without having to install all modules? Why am I having an import error if PyInstaller worked well and created a proper .exe? Thanks

0 Answers0