1、在引用rasterio时,from rasterio._base import gdal_version,显示错误:
ImportError: DLL load failed: 找不到指定的程序。
搜索发现是因为rasterio与GDAL版本不匹配导致的。
解决方案:
(1)卸载rasterio与gdal
conda remove rasterio gdal -y
如果卸载不成功,就直接使用pip卸载即可
pip uninstall rasterio
pip uninstall gdal
(2)使用conda重新安装
conda install rasterio gdal=2 -y
重新安装之后的版本:
不过注意导入 rasterio 之前需要先导入 gdal,否则会报错
from osgeo import gdal
import rasterio
2、出现绘图错误
搜索发现是因为matplotlib版本有冲突,所以从高版本降为低版本,原版本为3.5.3
pip uninstall matplotlib
pip install matplotlib==3.4.0
问题解决
3、在运行过程中出现Fail to allocate bitmap.
搜索原因是内存不足导致的,在import matplotlib.pyplot as plt前面加如下代码,可避免出现此问题
matplotlib.use('AGG')