Gdal_Python
Video Article

Install GDAL in Windows 10 Python 3.x Pipenv Virtual Environment

Watch Video

How to create a Python 3.x Virtual Environment using Pipenv and install the GDAL library for Spatial Data Science without OSGeo4W

Video Duration: Estimated 10-15 minutes

About This Video


Geospatial Data Abstraction Library (GDAL) is a library for translating raster and vector geospatial data formats. The library is written in C/C++ and hence for it to work with Python a wrapper class is written that wraps around the GDAL to allow its methods to be accessible.

More often than not, the installation of GDAL in Windows OS powered computers is painful and mostly fails especially when using Python virtual environments. In the next steps I will take you through installing GDAL in a virtual environment in Windows operating system, Python 3.x and Pipenv virtual environment.


Watch the video at Install GDAL in Windows 10 Python Environment and Like the video and Subscribe for more content.

Install Python and Pipenv


For this installation you should be familiar with command line or Windows PowerShell to interact with your computer. Windows PowerShell is used in this tutorial with Python 3.8

  • Use your browser to access Python 3.x Download Page and download the latest version of Python. For example, Python 3.9.5


Python Download Page

  • Install the downloaded python file ensuring to install the Python to windows path.

  • After installation start Windows PowerShell and make a folder using the following command. This can be done by creating a new folder via the file explorer.

bash
mkdir D://spatial_data_science

Change into the created folder using the change directory command.

bash
cd D://spatial_data_science

Install Pipenv using python command below.

bash
py -m pip install pipenv

Create a Pipenv virtual environment associated with the current folder and activate it.

bash
#Instantiate a virtual environment
py -m pipenv install

#Activate the virtual environment
py -m pipenv shell

Install GDAL in Windows 10 Python Virtual environment


Download the GDAL version binaries that correspond to your installed python version win32(x86) or win64(x64) from Python Extension Packages for Windows - Christoph Gohlke (uci.edu) .

For example: GDAL-3.2.2-cp38-cp38-win_amd64.whl downloads GDAL-3.2.2-cp38-cp38-win_amd64.whl binary which is intended for x64 Python 3.8 installation.



Install the downloaded binary to your virtual environment through pip command in Windows PowerShell:

bash
#pip install path\to\your\downloaded\file\filename

#For example:

pip install c:\users\johhny\Downloads\GDAL-3.2.2-cp38-cp38-win_amd64.whl


After this process the GDAL library is fully installed to your virtual environment and is ready to use with other libraries like Geopandas and Rasterio .



If you like this post check my YouTube Channel for more videos on Spatial Data Science.

About the Author

John Esther

John Esther

Visit Website

Join the Discussion