Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX: pip install of shapely does not work with geos #416

Closed
MarkWieczorek opened this issue Sep 22, 2016 · 4 comments
Closed

OSX: pip install of shapely does not work with geos #416

MarkWieczorek opened this issue Sep 22, 2016 · 4 comments

Comments

@MarkWieczorek
Copy link

Installing shapely via pip on OSX, and then try to use a routine in cartopy that relies on shapely results in the following error and kernel crash:

In [3]: ax.coastlines()
Out[3]: <cartopy.mpl.feature_artist.FeatureArtist at 0x1148419e8>

In [4]: Assertion failed: (0 != cs), function GEOSCoordSeq_getSize_r, file geos_ts_c.cpp, line 3797.
Abort

The can be fixed by installing shapely with the no-binary flag

pip install shapely --no-binary :all:
@sgillies
Copy link
Contributor

@MarkWieczorek thanks for the report. Can you tell me which version of Shapely you have here? The Shapely binary wheels for macosx that I uploaded to PyPI probably won't work well with cartopy unless the version is >= 1.5.16.

@MarkWieczorek
Copy link
Author

The version that is downloaded from pip is 1.5.17.

Collecting shapely
  Downloading Shapely-1.5.17-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (2.2MB)

@sgillies sgillies added this to the 1.6 milestone Oct 6, 2016
@sgillies
Copy link
Contributor

sgillies commented Oct 6, 2016

Broadly speaking, the problem is DLL Hell. You've built cartopy with one version of GEOS and Shapely's binaries are built with another version of GEOS (maybe the same release, but configured and compiled differently). The extension modules in the two packages are not compatible. Import Shapely first and cartopy isn't able to use the GEOS dynamic library that Shapely caused to be loaded. I could strive to make Shapely more compatible, and will, but there are limits to this and lots of different ways that users install GEOS on their systems: macports, Homebrew, the Kyngchaos installers. Being compatible with all of them would be difficult, especially since I have no great expertise with dynamic linking on OS X.

Bundling GEOS into the macosx Shapely wheels has so many benefits for developers that I don't want to abandon it. pip install shapely and it just works, no need to install GEOS separately. The same benefit that Numpy's wheels bring to developers (though GEOS is less of a bear than Numpy's C deps).

The workaround is to install Shapely with --no-binary shapely (not necessarily :all:) , which will let you build Shapely's extension modules using the same GEOS lib as you used to build cartopy. Thus the modules will be compatible.

Projects like cartopy can specify

--no-binary shapely
shapely>=1.5.17
...

in a pip requirements file to help out. I also expect that conda users aren't going to have this DLL problem as long as conda package developers do the right thing.

Longer term, I wonder if cartopy shouldn't move its GEOS dependency entirely to Shapely or vendorize Shapely in order to ensure extension module compatibility.

Next for me:

  • Document this issue clearly in the Shapely wiki and readme
  • Propose a couple changes to cartopy

@sgillies
Copy link
Contributor

sgillies commented Jan 1, 2018

See also #553.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants