1.7.0 breaks linux compatibility with pyinstaller
See original GitHub issueExpected behavior and actual behavior.
Expected: Shapely is able to load libgeos_c.so.1 in a pyinstaller-packaged application. Actual: Program throws an exception on startup:
Traceback (most recent call last):
File "/home/runner/work/inkstitch/inkstitch/inkstitch.py", line 8, in <module>
File "/home/runner/.local/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "/home/runner/work/inkstitch/inkstitch/lib/extensions/__init__.py", line 1, in <module>
File "/home/runner/.local/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "/home/runner/work/inkstitch/inkstitch/lib/extensions/auto_satin.py", line 5, in <module>
File "/home/runner/.local/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "/home/runner/work/inkstitch/inkstitch/lib/i18n.py", line 6, in <module>
File "/home/runner/.local/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "/home/runner/work/inkstitch/inkstitch/lib/utils/__init__.py", line 3, in <module>
File "/home/runner/.local/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "/home/runner/work/inkstitch/inkstitch/lib/utils/geometry.py", line 3, in <module>
File "/home/runner/.local/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "/home/runner/.local/lib/python2.7/site-packages/shapely/geometry/__init__.py", line 4, in <module>
File "/home/runner/.local/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "/home/runner/.local/lib/python2.7/site-packages/shapely/geometry/base.py", line 18, in <module>
File "/home/runner/.local/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "/home/runner/.local/lib/python2.7/site-packages/shapely/coords.py", line 8, in <module>
File "/home/runner/.local/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 396, in load_module
File "/home/runner/.local/lib/python2.7/site-packages/shapely/geos.py", line 196, in <module>
File "/home/runner/.local/lib/python2.7/site-packages/shapely/geos.py", line 184, in _geos_version
AttributeError: 'NoneType' object has no attribute 'GEOSversion'
This seems to happen because _lgeos
is None
. The logic in #485 doesn’t do anything if the geos_c library file is named libgeos_c.so.1
as happens when Shapely is installed NOT as a wheel. It seems to me as if everything would work if the outer else
clause were run, but it isn’t.
When installing Shapely as a wheel, the problem goes away. In case you’re curious, we were installing Shapely with --no-binary
to work around the very problem that #485 seems to fix. The wheel has libgeos_c in a different spot, and pyinstaller couldn’t find it.
Steps to reproduce the problem.
Package a python application that uses Shapely v1.7.0 using pyinstaller 3.3.1. Run the program.
Operating system
Linux 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Shapely version and provenance
Shapely 1.7.0 installed from pypi not as a whl (with pip install --no-binary
).
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top GitHub Comments
I’m going to close this. The entire category of errors involving dynamic loading of GEOS is going away in 2.0 and we won’t be doing anything about any of them in the meanwhile.
Fair enough. I don’t think I’m they one to do that since I don’t know much about pyinstaller. I do think I know enough about this particular bug to submit a PR, if you’re interested?