我无法让底图在我的 Mac 中使用 Python 工作。
我不断收到:
from mpl_toolkits.basemap import basemap
ImportError: No module named basemap
我做了什么:
brew install gdal
brew install gets
export GEOS_DIR=/usr/local/Cellar/geos/3.4.2/
basemap-1.0.7 $ python setup.py install
我也试过:
basemap-1.0.7 $ cd geos-3.3.3
basemap-1.0.7/geos-3.3.3 $ export GEOS_DIR=~/
basemap-1.0.7/geos-3.3.3 $ ./configure --prefix=$GEOS_DIR
basemap-1.0.7/geos-3.3.3 $ make
basemap-1.0.7/geos-3.3.3 $ make install
basemap-1.0.7/geos-3.3.3 $ cd ..
basemap-1.0.7 $ python setup.py install
他们都不适合我。我怎样才能让这个包在 MacOS Sierra 上工作?
原文由 pceccon 发布,翻译遵循 CC BY-SA 4.0 许可协议
你有没有设法让它工作?
我能够按照此处的说明在 Sierra 上安装 Basemap(也使用 Homebrew 作为其依赖项):http: //matplotlib.org/basemap/users/installing.html
一些注意事项,只是为了确保没有遗漏任何内容:
brew install gets
,尽管我认为这是一个错字,你实际上是指并在安装时使用了brew install geos
。export GEOS_DIR=/usr/local/Cellar/geos/3.5.0/
。可以通过查看 /usr/local/Cellar/geos/ 目录以查看安装了哪个版本来验证版本。source ~/.bash_profile
。这是我所做的完整列表:
下载 Basemap 1.0.7 源 tar 文件 ( https://sourceforge.net/projects/matplotlib/files/matplotlib-toolkits/ ),解压它。
将
export GEOS_DIR=/usr/local/Cellar/geos/3.5.0/
添加到我的 .bash_profile 中的新行,然后通过以下方式重新加载它:从解压缩的底图目录中:
使用
import mpl_toolkits.basemap as bm
在 python 脚本中导入底图(通过其他地方的教程),并能够确认它适用于生成的地图。