Skip to content

Instantly share code, notes, and snippets.

@underchemist
Last active November 14, 2020 17:59
Show Gist options
  • Save underchemist/a91fe2a9a130ab541be223265be21dcd to your computer and use it in GitHub Desktop.
Save underchemist/a91fe2a9a130ab541be223265be21dcd to your computer and use it in GitHub Desktop.
Install rasterio from source on windows
conda create -n gdal242 python=3.7
conda activate gdal242
conda install -c gdal==2.4.2
# from source with pip (MSVC build tools required)
git clone https://github.com/mapbox/rasterio.git
cd clone rasterio
set GDAL_VERSION=2.4.2
# if you have a newer conda you can use %CONDA_PREFIX%
# note: --no-use-pep517 seems to be required as a workaround
pip install --no-use-pep517 --global-option build_ext --global-option -I%CONDA_PREFIX%\Library\include --global-option -lgdal_i --global-option -L%CONDA_PREFIX%\Library\lib .
# from source with setup.py (MSVC build tools required)
git clone https://github.com/mapbox/rasterio.git
cd clone rasterio
set GDAL_VERSION=2.4.2
# currently, rasterio will always rerun build_ext when we call python setup.py install, so need to set include, and lib as env variables
set INCLUDE=%CONDA_PREFIX%\Library\include
set LIBPATH=%CONDA_PREFIX%\Library\lib
set LINK=%CONDA_PREFIX%\Library\lib\gdal_i.lib
# if you have a newer conda you can use %CONDA_PREFIX%
python setup.py install
# from conda
conda install -c conda-forge rasterio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment