Cartopy and matplotlib TypeError: unhashable type: 'MultiLineString'
Cartopy and matplotlib TypeError: unhashable type: 'MultiLineString'
我正在尝试按照 Cartopy 官方网站上提供的示例来尝试使用 Cartopy。它们都正常工作,但第一个
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()
plt.show()
所有线路都正常工作,但是一旦我 运行 plt.show() 命令,我就会收到以下错误消息:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1539, in __call__
return self.func(*args)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 278, in resize
self.show()
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 349, in draw
FigureCanvasAgg.draw(self)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.py", line 469, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1079, in draw
func(*args)
File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/home/mrvaita/python_workspace/gis_venv/local/lib/python2.7/site-packages/cartopy/mpl/geoaxes.py", line 359, in draw
inframe=inframe)
File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 2092, in draw
a.draw(renderer)
File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/home/mrvaita/python_workspace/gis_venv/local/lib/python2.7/site-packages/cartopy/mpl/feature_artist.py", line 113, in draw
{})
File "/usr/lib/python2.7/weakref.py", line 433, in setdefault
return self.data.setdefault(ref(key, self._remove),default)
TypeError: unhashable type: 'MultiLineString'
有人知道吗?
我的matplotlib版本是1.4.2,Cartopy版本是0.13.0
非常感谢您的帮助。
这是 https://github.com/SciTools/cartopy/issues/682 的 Cartopy 问题跟踪器上报告的一个问题。基本上,Shapely 在 1.5.12 和 1.5.13 之间改变了几何的可散列性。在我们发布新版本的 cartopy 之前,解决方法是将 shapely 的安装降级到 1.5.12。
HTH
我正在尝试按照 Cartopy 官方网站上提供的示例来尝试使用 Cartopy。它们都正常工作,但第一个
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()
plt.show()
所有线路都正常工作,但是一旦我 运行 plt.show() 命令,我就会收到以下错误消息:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1539, in __call__
return self.func(*args)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 278, in resize
self.show()
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 349, in draw
FigureCanvasAgg.draw(self)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.py", line 469, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1079, in draw
func(*args)
File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/home/mrvaita/python_workspace/gis_venv/local/lib/python2.7/site-packages/cartopy/mpl/geoaxes.py", line 359, in draw
inframe=inframe)
File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 2092, in draw
a.draw(renderer)
File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/home/mrvaita/python_workspace/gis_venv/local/lib/python2.7/site-packages/cartopy/mpl/feature_artist.py", line 113, in draw
{})
File "/usr/lib/python2.7/weakref.py", line 433, in setdefault
return self.data.setdefault(ref(key, self._remove),default)
TypeError: unhashable type: 'MultiLineString'
有人知道吗? 我的matplotlib版本是1.4.2,Cartopy版本是0.13.0
非常感谢您的帮助。
这是 https://github.com/SciTools/cartopy/issues/682 的 Cartopy 问题跟踪器上报告的一个问题。基本上,Shapely 在 1.5.12 和 1.5.13 之间改变了几何的可散列性。在我们发布新版本的 cartopy 之前,解决方法是将 shapely 的安装降级到 1.5.12。
HTH