2

I am using Window 10 64bit to create exe. However, the exe gives error below: File "rtree\core.py", line 126, in OSError: could not find or load spatialindex_c-64.dll [23324] Failed to execute script microwave_python_code

I tried below solutions ppl shared but still cannot solve the problem.

  1. --add-data=C:\path\to\spatialindex_c-64.dll;. to my build command
  2. pip uninstall rtree then install using 'Rtree-0.9.4-cp37-none-win_amd64.whl'
  3. install 'spatialindex-src-1.9.3.tar.gz'
  4. copied the 'spatialindex_c-64.dll' into rtee site package folder
  5. copied the 'spatialindex_c-64.dll' into exe folder

Anyone able to create working exe by doing above? I still face problem after trying above solutions. Anything else that I can do to get my exe works?

1 Answers1

3

I had the same issue, and I solved it using the final answer on http://pyinstaller.47505.x6.nabble.com/OSError-while-running-exe-td2997.html.

To solve it, find the .specs file that is made when building the .exe, and add two things to it:

from PyInstaller.utils.hooks import collect_dynamic_libs
...
a = Analysis(...
            binaries=collect_dynamic_libs("rtree"),
            ...)

That will find the .dll files used by rtree. After that, you can rebuild it with the command pyinstaller your_script_name.spec.

Dharman
  • 30,962
  • 25
  • 85
  • 135
nanleij
  • 41
  • 3
  • I have the same problem and If I print out `collect_dynamic_libs("rtree")` in .spec file, I get empty list. I assume it is not desirable output. Any idea why it is like this? – Kubson Mar 12 '21 at 19:16