1.下载 basemap 包
https://github.com/matplotlib/basemap/releases
注意:从电脑上下载tar.gz包再用winscp传上linux,我直接从linux中下载存在安装文件确实的问题。
2.解压
tar -zxvf basemap-1.2.1rel.tar.gz
3.安装依赖包
pip install numpy -i https://mirrors.aliyun.com/pypi/simple
pip install matplotlib -i https://mirrors.aliyun.com/pypi/simple
pip install pyproj -i https://mirrors.aliyun.com/pypi/simple
pip install pyshp -i https://mirrors.aliyun.com/pypi/simple
4.编译安装 geos 库
cd basemap-1.2.1rel/geos-3.3.3/
export GEOS_DIR=/usr/local
./configure --prefix=$GEOS_DIR
vim include/geos/platform.h
改:/* #undef HAVE_ISNAN */
为:#define HAVE_ISNAN 1 (这一步已默认修改了)
make
make install
5.安装 basemap
cd …
python setup.py install
6.测试
cd examples/
python simpletest.py
或者
python
from mpl_toolkits.basemap import Basemap
**重点来了:**此时,会报错:没有mpl_toolkits.basemap模块。在anaconda3安装目录下查看,发现我们的basemap没有在anaconda3/lib/python3.7/site-packages/mpl_toolkits目录下,因此,将
anaconda3/lib/python3.7/site-packages/basemap-1.2.1-py3.7-linux-x86_64.egg/mpl_toolkits
的下的basemap拷贝至
anaconda3/lib/python3.7/site-packages/mpl_toolkits
即可。
参考链接:https://www.cnblogs.com/luochunxi/p/12891574.html
https://blog.csdn.net/SSRS_CS_001/article/details/108256296?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight