GDAL 在 Databricks 集群运行时 12.2 LTS 上

huangapple go评论78阅读模式
英文:

GDAL on Databricks Cluster Runtime 12.2 LTS

问题

I need gdal in my course work.

After reading this post, I used init script as follows to install gdal into runtime 12.2 LTS

dbutils.fs.put("/databricks/scripts/gdal_install.sh", """
#!/bin/bash
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install -y cmake gdal-bin libgdal-dev python3-gdal""",
True)

The init script ran and cluster could start properly but when I run import gdal in the notebook, I get the following error:

ModuleNotFoundError: No module named 'gdal'

I also tried installing gdal into the cluster via Maven repository, it does not work either.

May I know what I can do to get gdal installed properly?

Thank you.

英文:

I need gdal in my course work.

After reading this post, I used init script as follows to install gdal into runtime 12.2 LTS

dbutils.fs.put("/databricks/scripts/gdal_install.sh","""
#!/bin/bash
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install -y cmake gdal-bin libgdal-dev python3-gdal""",
True)

The init script ran and cluster could start properly but when i run import gdal in notebook, i get the following error:

> ModuleNotFoundError: No module named 'gdal'

I also tried installing gdal into the cluster via Maven repository, it does not work either.

May I know what I can do to get gdal installed properly?

Thank you.

答案1

得分: 1

你可以按照以下方式安装 GDAL

在你的 init 脚本中修改代码如下,并重新启动集群。

dbutils.fs.put("/databricks/scripts/gdal_install.sh", """
#!/bin/bash
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install -y libgdal-dev
""",
True)

GDAL 在 Databricks 集群运行时 12.2 LTS 上

然后,在重新启动后,检查头文件版本如下。

%sh
gdal-config --version

GDAL 在 Databricks 集群运行时 12.2 LTS 上

并且使用 pip 安装相同版本的 gdal

在这里,我得到了 3.3.2

pip install GDAL==3.3.2

输出:

GDAL 在 Databricks 集群运行时 12.2 LTS 上

在 pip 安装后,你的导入语句将起作用。

英文:

You can follow below way to install GDAL.

Alter the code in your init script as below and restart the cluster.

dbutils.fs.put("/databricks/scripts/gdal_install.sh","""
#!/bin/bash
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install -y libgdal-dev""",
True)

GDAL 在 Databricks 集群运行时 12.2 LTS 上

After, restarting check the header version as below.

%sh
gdal-config --version

GDAL 在 Databricks 集群运行时 12.2 LTS 上

And the same version of gdal should be installed via pip.

Here, I got 3.3.2.

pip install GDAL==3.3.2

Output:

GDAL 在 Databricks 集群运行时 12.2 LTS 上

After pip install your import statements will work.

huangapple
  • 本文由 发表于 2023年8月4日 22:04:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76836677.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定