I\'m trying to use ogr
module, I tried to install it with pip got the errors :
Could not find a version that satisfies the requirement ogr
(fro
Please first install python GDAL package then import something like this
from osgeo import ogr
Or you can follow below link [https://pypi.org/project/GDAL/]
For Windows:
Go to the gisinternals site select the download link for you architecture and compiler, search for the Generic installer for the GDAL core components
msi, download and install as typical
.
You have two options, the second requires that you have pip
installed and the first one must set the path variables.
1.) Download the Installer for the GDAL python bindings (requires to install the GDAL core)
msi, and install.
Open cmd and type:
setx PATH "%PATH%;C:\Program Files (x86)\GDAL"
setx PATH "%GDAL_DATA%;C:\Program Files (x86)\GDAL\gdal-data"
setx PATH "%GDAL_DRIVER_PATH%;C:\Program Files (x86)\GDAL\gdalplugins"
*Note that each one of the commands above is a separate one, so copy-paste and enter, each one separately. If you downloaded the x64 version just remove the (x86).
OR
2.) Go to the unofficial python wheels site search for the version that matches the core you have already installed, download. Then, copy the path to the file you just donwloaded, in my case:
C:\Users\admin\donwloads\GDAL‑2.2.4‑cp27‑cp27m‑win_amd64.whl
Once you have the path, type windows key plus r, than cmd, enter and type:
pip install "your path to the wheel you have downloaded"
in my case it looks something like:
pip install C:\Users\admin\donwloads\GDAL‑2.2.4‑cp27‑cp27m‑win_amd64.whl (look where the file is located).
To test just run a cmd and type:
python
Once you are in the python shell:
import gdal
If you need to install the library for Mac, take a look at the tutorial written by me, or add a comment so that I update the answer.
References: UCLA