python环境,原本有gdal2,升级gdal3时pip卸载后使用whl安装:
pip uninstall gdal
pip install GDAL-3.4.2-cp37-cp37m-win_amd64.whl
使用时,Import gdal出现错误:
ModuleNotFoundError: No module named 'gdal'
解决办法:在Lib\site-packages目录下创建以下文件:
gdal.py
# import osgeo.gdal as a convenience
from osgeo.gdal import deprecation_warn
deprecation_warn('gdal')from osgeo.gdal import *
ogr.py
# import osgeo.ogr as a convenience
from osgeo.gdal import deprecation_warn
deprecation_warn('ogr')from osgeo.ogr import *
osr.py
# import osgeo.osr as a convenience
from osgeo.gdal import deprecation_warn
deprecation_warn('osr')from osgeo.osr import *