cartopy icon indicating copy to clipboard operation
cartopy copied to clipboard

Shapely 1.8.1 causes cartopy to crash

Open melanopsis opened this issue 3 years ago • 5 comments

Description

Shapely 1.8.1 (and 1.8.1.post1) causes cartopy to crash. Downgrading Shapely to 1.8.0 fixes the issue.

Code to reproduce

import cartopy.crs as ccrs
import matplotlib.path as mpath
import matplotlib.pyplot as plt

fig = plt.figure(figsize=[10, 5])
ax1 = fig.add_subplot(1, 2, 1, projection=ccrs.SouthPolarStereo())
ax2 = fig.add_subplot(1, 2, 2, projection=ccrs.SouthPolarStereo(),
                      sharex=ax1, sharey=ax1)
fig.subplots_adjust(bottom=0.05, top=0.95,
                    left=0.04, right=0.95, wspace=0.02)

# Limit the map to -60 degrees latitude and below.
ax1.set_extent([-180, 180, -90, -60], ccrs.PlateCarree())

plt.show()

Traceback

munmap_chunk(): invalid pointer
Aborted (core dumped)
Full environment definition

Operating system

Linux

Cartopy version

0.20.2

pip list

relevant packages

matplotlib                 3.5.1
numpy                      1.22.2
pyproj                     3.3.0
pyshp                      2.2.0
Shapely                    1.8.1.post1

melanopsis avatar Feb 19 '22 00:02 melanopsis

I think this is running into the GEOS library linkings between the two libraries seen in #805. This only happens with the shapely wheels as far as I can tell.

I am able to get a working installation by forcing an install from source: pip install --upgrade --no-binary shapely shapely

greglucas avatar Feb 22 '22 14:02 greglucas

@melanopsis If I may ask, how did you figure out that the error was caused by the latest version of shapely? I could not find a logical route that points to this error being caused by shapely when trying to use cartopy. I am just curious, thanks.

hastiin-manuelito avatar Mar 06 '22 16:03 hastiin-manuelito

General experience that crashes like that are caused by CartoPy's compiled code and what it's linking to, which is PROJ and GEOS/shapely. Most of the time a conflict between the versions of GEOS that shapely and Cartopy are independently built against and linked to is the cause.

dopplershift avatar Mar 08 '22 19:03 dopplershift

@hastiin-manuelito After a platform update, where all python packages are updated, I noticed that cartopy test notebook was failing. Checking the list of updated packages (something I keep track of after each platform update) showed that cartopy itself wasn't updated but Shapely, one of its dependencies, was.

melanopsis avatar Mar 09 '22 01:03 melanopsis

@melanopsis @dopplershift Thanks for taking the time to respond, it is much appreciated! This helps me learn more about tracing errors, etc. I am fairly green in all of "this".

hastiin-manuelito avatar Mar 11 '22 16:03 hastiin-manuelito

Whose fault is this? Is it shapely's or Cartopy's??? It is a mess

yucsong avatar Jun 11 '23 20:06 yucsong

We have just released v0.22 which should help with the compatibility between packages and installation much easier. Please open a new issue if you are still having problems.

greglucas avatar Aug 05 '23 02:08 greglucas