# 导入所需的库
import cartopy
import matplotlib as mpl
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
print(f"cartopy version: {cartopy.__version__}")
# 创建画布以及ax
fig = plt.figure()
ax = fig.add_subplot(111, projection=ccrs.PlateCarree())
# 调用ax的方法画海岸线
ax.coastlines()
plt.show()
使用上述代码进行检验时,可以显示cartopy的版本号
![](https://img-blog.csdnimg.cn/img_convert/b3e4c25174d45f4b8d8b22fb6916af1e.png)
但是会报出如下错误: