# An error occurs when cartopy library uses the coastlines() command

Reinstall the system, resulting in the need to reconfigure python. Python version 3.7.9 and cartopy version 0.19.0.post1 are used

Example code:

``````import numpy as np
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
from cartopy.mpl.ticker import LongitudeFormatter,LatitudeFormatter
dlon,dlat=60,30
xticks=np.arange(0,360.1,dlon)
yticks=np.arange(-90,90.1,dlat)
fig=plt.figure(figsize=(6,5))
ax.coastlines()
gl=ax.gridlines(crs=ccrs.PlateCarree(),draw_labels=False,linewidth=1,linestyle=":",color="k",alpha=0.8)
gl.xlocator=mticker.FixedLocator(xticks)
gl.ylocator=mticker.FixedLocator(yticks)
ax.set_xticks(xticks,crs=ccrs.PlateCarree())
ax.set_yticks(yticks,crs=ccrs.PlateCarree())
ax.xaxis.set_major_formatter(LongitudeFormatter(zero_direction_label=True))
ax.yaxis.set_major_formatter(LatitudeFormatter())
plt.show()``````

The first time you use this command, you need to download the corresponding coalistline file, but there is a problem with the website in the program and you can’t download it. You need to download the file yourself on the earthnatural official website. Place the file in C: \ users \ XXXX \. Local \ share \ cartopy \ shapefiles \ natural_ Under the earth \ physical path, if the program still reports an error when running, you need to delete the path (. Local \ share \ cartopy \ shapefiles \ natural_earth \ physical) and run it again. After generating the path of the same path, copy the downloaded physical into physical, run it again, and no error will be reported. Code reference Python meteorological drawing tutorial (VII) — cartopy
{"ft_lang_label":"__label__en","ft_lang_prob":0.54820114,"math_prob":0.5248551,"size":2998,"snap":"2021-31-2021-39","text_gpt3_token_len":776,"char_repetition_ratio":0.09418838,"word_repetition_ratio":0.020997375,"special_character_ratio":0.24116078,"punctuation_ratio":0.1764706,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96512425,"pos_list":[0,1,2],"im_url_duplicate_count":[null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-25T06:33:39Z\",\"WARC-Record-ID\":\"<urn:uuid:d1ecf5cf-d596-40ce-937f-7813fcf998d0>\",\"Content-Length\":\"35940\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e5d607a3-2ac8-4747-ae0d-c07821e8b4b4>\",\"WARC-Concurrent-To\":\"<urn:uuid:6d4843bd-24bb-4f0e-af67-e11a43dce2dc>\",\"WARC-IP-Address\":\"104.21.83.61\",\"WARC-Target-URI\":\"https://programmerah.com/an-error-occurs-when-cartopy-library-uses-the-coastlines-command-37457/\",\"WARC-Payload-Digest\":\"sha1:DVOQ4CSUO4SRGZYSX2KUYSTCJH2ZHROU\",\"WARC-Block-Digest\":\"sha1:SF2ID5XUZ3KDH7WHSX2CH7QGFHQQPBG3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780057598.98_warc_CC-MAIN-20210925052020-20210925082020-00416.warc.gz\"}"}