cartopy
cartopy copied to clipboard
Shapely 1.8.1 causes cartopy to crash
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
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
@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.
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.
@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 @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".
Whose fault is this? Is it shapely's or Cartopy's??? It is a mess
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.