我已经在运行El Capitan 10.11.6和Python 3.4的Mac上安装了Python映射工具Cartopy。我可以使用Cartopy成功绘制一些地图,但在某些情况下,Python内核会因分割错误11而死亡。生成一些 - 但不是全部时,Python 3.4崩溃 - 具有段错误的Cartopy映射11
我想要一个安装程序,可以在需要时轻松从我的计算机中删除。因此,我安装了Python 3.4和使用fink必要的依赖关系:
$ fink install python34
$ fink install gdal2
$ fink install gdal2-dev
$ fink install proj
$ fink install libproj9
我然后使用pyvenv创建的虚拟环境(但也试过的virtualenv和VENV)和活化它。
在激活的虚拟环境中,我使用PIP安装:
$ pip install cython # Successfully installed cython-0.25.2
$ pip install numpy # Successfully installed numpy-1.12.1
$ pip install shapely # Successfully installed shapely-1.5.17.post1
$ pip install pyshp # Successfully installed pyshp-1.2.10
$ pip install pandas # Successfully installed pandas-0.19.2 python-dateutil-2.6.0 pytz-2017.2 six-1.10.0
$ pip install matplotlib # Successfully installed cycler-0.10.0 matplotlib-2.0.0 pyparsing-2.2.0
$ pip install pillow # Successfully installed olefile-0.44 pillow-4.1.0
$ pip install pyepsg # Successfully installed pyepsg-0.3.1
$ pip install scipy # Successfully installed scipy-0.19.0
$ pip install OWSLib # Successfully installed OWSLib-0.14.0 pyproj-1.9.5.1 requests-2.13.0
$ pip install mock # Successfully installed mock-2.0.0 pbr-3.0.0
$ pip install nose # Successfully installed nose-1.3.7
$ pip install pep8 # Successfully installed pep8-1.7.0
$ pip install jupyter # Successfully installed MarkupSafe-1.0 appnope-0.1.0 backports-abc-0.5 bleach-2.0.0 decorator-4.0.11 entrypoints-0.2.2 html5lib-0.999999999 ipykernel-4.6.1 ipython-6.0.0 ipython-genutils-0.2.0 ipywidgets-6.0.0 jedi-0.10.2 jinja2-2.9.6 jsonschema-2.6.0 jupyter-1.0.0 jupyter-client-5.0.1 jupyter-console-5.1.0 jupyter-core-4.3.0 mistune-0.7.4 nbconvert-5.1.1 nbformat-4.3.0 notebook-5.0.0 pandocfilters-1.4.1 pexpect-4.2.1 pickleshare-0.7.4 prompt-toolkit-1.0.14 ptyprocess-0.5.1 pygments-2.2.0 pyzmq-16.0.2 qtconsole-4.3.0 simplegeneric-0.8.1 terminado-0.6 testpath-0.3 tornado-4.5.1 traitlets-4.3.2 typing-3.6.1 wcwidth-0.1.7 webencodings-0.5.1 widgetsnbextension-2.0.0
上面似乎满足所有在列出的Cartopy扶养要求:http://scitools.org.uk/cartopy/docs/v0.15/installing.html
然后我装Cartopy,确保建立针对
pip install --global-option=build_ext --global-option="-I/sw/opt/libgeos3.5.0/include" --global-option="-L/sw/opt/libgeos3.5.0/lib" cartopy
# Successfully installed cartopy-0.14.2
我既可以在Jupyt运行Python:(如果这是正确的术语)用Fink安装了GEOS库呃笔记本或在终端,它允许我导入Cartopy没有错误。我从Cartopy网站下载了一些示例代码来测试安装。
下面的例子非常完美:
import matplotlib
matplotlib.use("TkAgg")
cartopy.crs as ccrs
import matplotlib.pyplot as plt
ax = plt.axes(projection=ccrs.Mollweide())
ax.stock_img()
plt.show()
至于这样做代码:
import os
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
from cartopy import config
import cartopy.crs as ccrs
fig = plt.figure(figsize=(8, 12))
# get the path of the file. It can be found in the repo data directory.
fname = os.path.join(config["repo_data_dir"],
'raster', 'sample', 'Miriam.A2012270.2050.2km.jpg'
)
img_extent = (-120.67660000000001, -106.32104523100001, 13.2301484511245, 30.766899999999502)
img = plt.imread(fname)
ax = plt.axes(projection=ccrs.PlateCarree())
plt.title('Hurricane Miriam from the Aqua/MODIS satellite\n'
'2012 09/26/2012 20:50 UTC')
# set a margin around the data
ax.set_xmargin(0.05)
ax.set_ymargin(0.10)
# add the image. Because this image was a tif, the "origin" of the image is in the
# upper left corner
ax.imshow(img, origin='upper', extent=img_extent, transform=ccrs.PlateCarree())
ax.coastlines(resolution='50m', color='black', linewidth=1)
# mark a known place to help us geo-locate ourselves
ax.plot(-117.1625, 32.715, 'bo', markersize=7, transform=ccrs.Geodetic())
ax.text(-117, 33, 'San Diego', transform=ccrs.Geodetic())
plt.show()
但这种代码导致内核崩溃:
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
import cartopy
ax = plt.axes(projection=cartopy.crs.PlateCarree())
ax.add_feature(cartopy.feature.LAND)
ax.add_feature(cartopy.feature.OCEAN)
ax.add_feature(cartopy.feature.COASTLINE)
ax.add_feature(cartopy.feature.BORDERS, linestyle=':')
ax.add_feature(cartopy.feature.LAKES, alpha=0.5)
ax.add_feature(cartopy.feature.RIVERS)
ax.set_extent([-20, 60, -40, 40])
plt.show()
时输入代码在终点线逐行,所有的线路都没有问题,直到最后两个输入。
在命令行产生唯一的错误信息是:
Segmentation fault: 11
有没有人遇到的一个原因,为此问题的解决方案?
您是否可以将您正在查看的错误消息复制/粘贴到您的帖子末尾。这可能有助于他人识别问题。 – ajdawson
唯一的消息是“分段错误:11”。已添加到问题。 – user1718097