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 *
在Python环境中,从gdal2升级到gdal3时遇到ImportError。卸载并使用whl文件安装GDAL-3.4.2后,模块gdal未找到。解决方法是在Libsite-packages目录下创建gdal.py、ogr.py和osr.py文件,导入osgeo中的对应模块。
1772

被折叠的 条评论
为什么被折叠?



