GDAL environment deployment under Windows

1. Python offline package download

Download link: https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal

Find the whl file of your own version corresponding to gdal in alphabetical order. If you install 32-bit Python, download the 32-bit gdal package, and if you install the 64-bit python, download the 64-bit gdal package. Similarly, for example, GDAL-3.0.1-cp36-cp36m-win64.whl downloaded here (cp36 stands for version 3.6.0, win64 stands for 64-bit Python)
Insert picture description here

2. Virtualenv installation and use

1. Virtualenv installation environment

cd G:\mypython3\gdal  # 进入要创建的目录位置
pip install virtualenv
pip install virtualenvwrapper  # 这是对virtualenv的封装版本,一定要在virtualenv后安装 

virtualenv venv   # 创建一个名字为venv的虚拟环境
virtualenv -p python3 venv  # 如果安装了多个python版本,如py2和py3,需要指定使用哪个创建虚拟环境
# 进入虚拟环境
cd venv
# 进入相关的启动文件夹
cd Scripts

activate  # 启动虚拟环境
deactivate # 退出虚拟环境

2. GDAL package installation

#在虚拟环境中安装
pip install G:\gdal\GDAL-3.1.2-cp36-cp36m-win_amd64.whl

#测试
from osgeo import gdal

After the installation and deployment is complete, execute the python xx.py file

In addition, you can also install the GDAL installation package to the Python local Lib and call it globally.

Guess you like

Origin blog.csdn.net/suntongxue100/article/details/108445497