I'm looking to install GDAL for Python. The first thing I did is installing Python, then I install OSGeo including its library GDAL, then in CMD when I type pip install gdal
I get this error
ERROR: Could not build wheels for GDAL, which is required to install pyproject.toml-based projects
then I tried to download the wheel required in this link https://www.lfd.uci.edu/~gohlke/pythonlibs/ but I didn't find it.
Does anyone know what could be the solution of my issue?
-
1That page is no longer supported, but Christoph Gohlke has kindly opened an alternative for these binary wheels, I guess: cgohlke.com Please check and drop a line if it worked for you.PDash– PDash2024年02月03日 10:24:02 +00:00Commented Feb 3, 2024 at 10:24
3 Answers 3
An alternative option is to use the conda package/environment manager. You can
- install e.g. miniforge
- start the installed "Miniforge prompt"
- create a new environment with e.g. the name gdal with the command
conda create --name gdal
- activate this new environment with
conda activate gdal
- install gdal with:
conda install gdal
I found the version I needed here: https://download.lfd.uci.edu/pythonlibs/archived/GDAL-3.4.3-cp311-cp311-win_amd64.whl
Note this needs Python 3.11 and it will not work with Python 3.12.
After downloading I placed the wheel file at the project root and installed it using pip.
If you already use OSGeo4W, just install its python-gdal
package.
Otherwise you are mixing potentially (or rather, probably) incompatible packages.
Also, OSGeo4W comes with its own, isolated Python installation, so your installation of a system-wide Python did nothing useful if you are planning to use OSGeo4W.