[Qgis-user] QGIS 3 Standalone Python Script

DT dmofot at gmail.com
Mon Aug 13 12:32:55 PDT 2018


Just had another standalone path issue.  Not sure if this is a Shapely bug,
QGIS packaging bug, or maybe not a bug at all, just a path issue.  Again,
versions:
OSX, version 10.13.6
Python 3.6.6
QGIS 3.2.1

In python, I tried:

`from shapely.geos import geos_version`

and got the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shapely/geos.py",
line 111, in <module>
    _lgeos = load_dll('geos_c', fallbacks=alt_paths)
  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/shapely/geos.py",
line 56, in load_dll
    libname, fallbacks or []))
OSError: Could not find lib geos_c or load any of its variants
['/Library/Frameworks/GEOS.framework/Versions/Current/GEOS',
'/opt/local/lib/libgeos_c.dylib'].

Shapely and the GEOS framework were installed by the QGIS 3.2.1 install.
After further digging, it turns out that
`/Library/Frameworks/GEOS.framework/Versions/Current` is a symbolic link to
version `3`, but there is no version `3`, just a version `3B`.  The fix was
to export the DYLD_LIBRARY_PATH in the shell or add it directly into the
script (or alternatively I could have changed the symbolic link):

shell - `export
DYLD_LIBRARY_PATH=/Library/Frameworks/GEOS.framework/Versions/3B/unix/lib`
script - `os.environ['DYLD_LIBRARY_PATH'] =
'/Library/Frameworks/GEOS.framework/Versions/3B/unix/lib'`

DT

On Mon, Aug 6, 2018 at 2:47 PM, DT <dmofot at gmail.com> wrote:

> Thanks William!  All is working now.
>
> Chris - here's what is working for me:
> https://gist.github.com/dmofot/94345126db10660053ccfb0d76a1e32a
>
> and I'm just passing the layers (full path) into the script.  For example,
> /Users/<user>/Documents/<shp_filename.shp>
>
> DT
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20180813/025ad9e7/attachment.html>


More information about the Qgis-user mailing list