cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

GDAL on Databricks Cluster Runtime 12.2 LTS

NC
New Contributor III

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.

 

 

 

 

 

 

 

 

 

 

 

4 REPLIES 4

Debayan
Databricks Employee
Databricks Employee

Hi, Could you please confirm if apt get install gdal was already tried? 

You can try as below: 

apt-get update && apt-get upgrade; apt-get install gdal*;

Please tag @Debayan with your next comment, which will get me notified. Thanks!

NC
New Contributor III

Hi @Debayan

Do you mean this:?

dbutils.fs.put("/databricks/scripts/gdal_install.sh","""
#!/bin/bash
apt-get update && apt-get upgrade
apt-get install gdal*

""", True)

 

Debayan
Databricks Employee
Databricks Employee

Hi, I think I understood the issue, for the no module found error sometimes you need to clean the apt list , something like below: 

%sh
rm -r /var/cache/apt/archives/* /var/lib/apt/lists/*
sudo apt-get clean
sudo apt-get update
sudo add-apt-repository -y ppa:ubuntugis/ppa && apt-get update
sudo apt-get install -y gdal-bin libgdal-dev (or gdal*)

Matt_C
New Contributor II

Hi, in case anyone is still struggling here. I found I could not get the init script approach to work, but if I just run a shell command to install gdal at the start of my notebook it works fine. You might note, however, that this installs gdal version 3.4.1 which is a bit dated (Jan 4, 2022). My understanding is that this is because "the Databricks standard image is itself based on Ubuntu 18.04 and GDAL 2.2.3 is the latest version available on this distribution" - see this Medium article

 

 

%sh
sudo apt-get install -y cmake gdal-bin libgdal-dev python3-gdal

 

 

%python
from osgeo import gdal
gdal.__version__

 

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group