简体   繁体   English

如何在 Google Colab 上快速安装 GDAL?

[英]How to install GDAL on Google Colab fast?

I can install GDAL in Google Colab by running the cell:我可以通过运行单元在Google Colab中安装 GDAL:

%%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?我怎样才能更快地安装gdal

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.我设法做到了,但是在 Colab kernel 重启后,我必须再次等待上述单元格运行。

GDAL is already pre-installed in Google Colab, so you only have to import it when starting a notebook GDAL 已预装在 Google Colab 中,因此您只需在启动笔记本时导入它

import gdal
!gdalinfo --version

GDAL 2.2.3, released 2017/11/20 GDAL 2.2.3,2017/11/20 发布

It's not the most recent version of GDAL though, but for your sample code it should be sufficient.虽然它不是最新版本的 GDAL,但对于您的示例代码来说应该足够了。

By the way, for a full list of pre-installed python libraries in Google Colab, run:顺便说一句,要获得 Google Colab 中预安装的 python 库的完整列表,请运行:

!pip freeze

Using install conda package to google colab , this works:使用install conda package 到 google colab ,这有效:

%%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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM