qgis / QGIS-Mac-Packager

Scripts for Official QGIS MacOS Packages
https://www.qgis.org
GNU General Public License v2.0
55 stars 21 forks source link

Shapely cannot find GEOS library libgeos_c.dylib #60

Closed jlayt closed 4 years ago

jlayt commented 4 years ago
QGIS version 3.14.1-Pi QGIS code revision de08d6b71d
Compiled against Qt 5.12.3 Running against Qt 5.12.3
Compiled against GDAL/OGR 2.4.1 Running against GDAL/OGR 2.4.1
Compiled against GEOS 3.7.2-CAPI-1.11.2 Running against GEOS 3.7.2-CAPI-1.11.2 b55d2125
Compiled against SQLite 3.28.0 Running against SQLite 3.28.0
PostgreSQL Client Version 11.3 SpatiaLite Version 4.3.0a
QWT Version 6.1.4 QScintilla2 Version 2.11.1
Compiled against PROJ 5.2.0 Running against PROJ Rel. 5.2.0, September 15th, 2018
OS Version macOS 10.15
Active python plugins numericalDigitize; LPGetLibraryInfo; plaingeometryeditor; LPMaps; ArkSpatial; MemoryLayerSaver; LPFigureBuilder; plugin_reloader; processing; db_manager; MetaSearch

We have a private python plugin that uses Shapely to do some processing. I finally uninstalled QGIS 2 from our company machines and it broke the plugin as Shapely could no longer find GEOS, as removing QGIS 2 removed the /Library/Frameworks/GEOS.framework copy of GEOS.

QGIS 3 seeks first to load GEOS for use in Shapely from /Applications/QGIS3.14.app/Contents/Frameworks/Python.framework/Versions/Current/lib/libgeos_c.dylib but cannot find it, so tries to fallback to /Library/Frameworks. I have worked-around the issue by pushing out GEOS as a separate package installed in /Library/Frameworks, but I assume that it should be finding the built-in copy of GEOS to prevent version issues.

Stacktrace:

Couldn't load plugin 'ArkSpatial' 

OSError: Could not find lib geos_c or load any of its variants ['/Applications/QGIS3.14.app/Contents/Frameworks/Python.framework/Versions/Current/lib/libgeos_c.dylib', '/Library/Frameworks/GEOS.framework/Versions/Current/GEOS', '/opt/local/lib/libgeos_c.dylib']. 
Traceback (most recent call last):

...

  File "/Users/j.layt/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ArkSpatial/ark/lib/core/geometry.py", line 27, in 
    from shapely.geometry import LineString, MultiLineString, Point
  File "/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 743, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python/shapely/geometry/__init__.py", line 4, in 
    from .base import CAP_STYLE, JOIN_STYLE
  File "/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 743, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python/shapely/geometry/base.py", line 17, in 
    from shapely.coords import CoordinateSequence
  File "/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 743, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python/shapely/coords.py", line 8, in 
    from shapely.geos import lgeos
  File "/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 743, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python/shapely/geos.py", line 111, in 
    _lgeos = load_dll('geos_c', fallbacks=alt_paths)
  File "/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python/shapely/geos.py", line 56, in load_dll
    libname, fallbacks or []))
OSError: Could not find lib geos_c or load any of its variants ['/Applications/QGIS3.14.app/Contents/Frameworks/Python.framework/Versions/Current/lib/libgeos_c.dylib', '/Library/Frameworks/GEOS.framework/Versions/Current/GEOS', '/opt/local/lib/libgeos_c.dylib'].

Python version: 3.7.3 (default, Mar 27 2019, 09:23:15) [Clang 10.0.1 (clang-1001.0.46.3)] 
QGIS version: 3.14.1-Pi Pi, de08d6b71d 

Python Path:
/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python
/Users/j.layt/Library/Application Support/QGIS/QGIS3/profiles/default/python
/Users/j.layt/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
/Applications/QGIS3.14.app/Contents/MacOS/../Resources/python/plugins
/Applications/QGIS3.14.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/site-packages
/Applications/QGIS3.14.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7
/Applications/QGIS3.14.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python37.zip
/Applications/QGIS3.14.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/site-packages/geos
/Applications/QGIS3.14.app/Contents/Resources/python
/Applications/QGIS3.14.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/lib-dynload
/Users/j.layt/Library/Application Support/QGIS/QGIS3/profiles/default/python
PeterPetrik commented 4 years ago

This is related to https://github.com/Toblerity/rtree/issues/56

please open Terminal, run

export SPATIALINDEX_C_LIBRARY=/Applications/QGIS3.14.app/Contents/MacOS/lib/libgeos_c.1.dylib

and then run QGIS

open /Applications/QGIS3.14.app