1. 下载 basemap 包
https://github.com/matplotlib/basemap/releases
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
为:#define HAVE_ISNAN 1
make
make install
5. 安装 basemap
cd ..
python setup.py install
6. 测试 cd examples/ python simpletest.py
FROM harbor-test.ecoweather.cn/ytq-datacenter_data-handle/python:3.7 WORKDIR /home COPY . /home RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple \ && unzip geos-3.8.1.zip \ && cd geos-3.8.1/ \ && export GEOS_DIR=/usr/local \ && chmod 777 ./configure \ && ./configure --prefix=$GEOS_DIR \ && make;make install \ && cd /home \ && rm -rf geos-3.8.1 \ && apt update -y \ && apt-get install build-essential python3-dev libssl-dev libffi-dev libxml2 libxml2-dev libxslt1-dev zlib1g-dev -y\ && pip install basemap-1.2.1rel.tar.gz \ && rm basemap-1.2.1rel.tar.gz
requirements.txt
pyshp
pyproj
numpy
matplotlib
参考 https://lumingdong.cn/install-basemap-under-linux.html#comment-201