英文:
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)
然后,在重新启动后,检查头文件版本如下。
%sh
gdal-config --version
并且使用 pip 安装相同版本的 gdal
。
在这里,我得到了 3.3.2。
pip install GDAL==3.3.2
输出:
在 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)
After, restarting check the header version as below.
%sh
gdal-config --version
And the same version of gdal
should be installed via pip.
Here, I got 3.3.2.
pip install GDAL==3.3.2
Output:
After pip install your import statements will work.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论