django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal302", "gdal301", "gdal300", "gdal204", "gdal203", "gdal202", "gdal201", "gdal20"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

 

Could not build wheels for gdal, which is required to install pyproject.toml-based projects
pip install gdal
ERROR: Failed building wheel for gdal
Failed to build gdal
ERROR: Could not build wheels for gdal, which is required to install pyproject.toml-based projects


======================================================================================================================================

import gdal导入失败的问题,但from osgeo import gdal导入成功


在python安装各种环境包的文件夹下,如: \Lib\site-packages\ 文件夹下,新建 gdal.py 文件,将以下代码复制进去:

# import osgeo.gdal as a convenience
from osgeo.gdal import deprecation_warn
deprecation_warn('gdal')
from osgeo.gdal import * 



解决方案:
1)离线安装
pip install GDAL-3.4.3-cp38-cp38-win_amd64.whl

2)添加path:
该路径为 gdal304.dll 的路径
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.

pip install gdal  在Windows系统上安装gdal_sed

 3)修改

搜索 gdal3*dll ,找到路径

修改文件

pip install gdal  在Windows系统上安装gdal_sed_02

 4)重启IDE,重启Windows