Search code examples
pythonmakefilegoogle-colaboratorygdalyum

How to install GDAL on Google Colab fast?


I can install GDAL in Google Colab by running the cell:

%%shell
sudo yum -y update
sudo yum-config-manager --enable epel
sudo yum -y install make automake gcc gcc-c++ libcurl-devel proj-devel geos-devel
cd /tmp
curl -L http://download.osgeo.org/gdal/2.0.0/gdal-2.0.0.tar.gz | tar zxf -
cd gdal-2.0.0/
./configure --prefix=/usr/local --without-python
make -j4
sudo make install
cd /usr/local
tar zcvf ~/gdal-2.0.0-amz1.tar.gz *

Using this answer.

However, it takes way more than half an hour for this cell to complete.

How could I install gdal faster?

My aim is to run the code in this answer. I have managed to do it, but after a Colab kernel restart, I have to wait again for the above cell to run.


Solution

  • Using install conda package to google colab, this works:

    %%shell
    wget -c https://repo.anaconda.com/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh
    chmod +x Miniconda3-4.5.4-Linux-x86_64.sh
    bash ./Miniconda3-4.5.4-Linux-x86_64.sh -b -f -p /usr/local
    conda install -q -y --prefix /usr/local python=3.6 gdal