本文针对
1. 下载并安装tar.gz包
下载链接osgeo · PyPI
下载完之后进入下载目录
tar -zvxf osgeo-0.0.1.tar.gz cd osgeo-0.0.1 python setup.py develop
显示以下日志
running egg_info writing osgeo.egg-info/PKG-INFO writing dependency_links to osgeo.egg-info/dependency_links.txt writing top-level names to osgeo.egg-info/top_level.txt reading manifest file 'osgeo.egg-info/SOURCES.txt' writing manifest file 'osgeo.egg-info/SOURCES.txt' running build_ext Creating /root/miniconda3/lib/python3.11/site-packages/osgeo.egg-link (link to .) Adding osgeo 0.0.1 to easy-install.pth file Installed /root/Downloads/osgeo-0.0.1 Processing dependencies for osgeo==0.0.1 Finished processing dependencies for osgeo==0.0.1
即安装成功
2.导入osgeo和gdal
此时导入osgeo和gdal会报错,显示没有osgeo模块
>>> import osgeo Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'osgeo' >>> from osgeo import gdal Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'osgeo'
解决方法,安装gdal即可
conda install gdal
安装结束后,再次导入不再报错
>>> import osgeo >>> from osgeo import gdal