cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to install R geospatial libraries raster, terra, sf, ncdf4, etc

ArturoNuor
New Contributor III

When trying to install any of this R libraries from a cmd cell/block on a notebook, or from the UI in the cluster I receive the same error,seeming that are unable to install dependecies.

Warning in utils::install.packages(pkgs, ...) :

installation of package ‘*****’ had non-zero exit status

Can anyone help me with this?

1 ACCEPTED SOLUTION

Accepted Solutions

ArturoNuor
New Contributor III

For the next soul looking for an answer, I managed to solve the issue with the next 2 Init scripts, it gets tricky in the apt or apt-get, that was the issue, sometimes it did update, sometimes it didn't, making it possible to find libmysqlclient21.

1)

%sh

sudo rm -r /var/lib/apt/lists/* 

sudo apt clean && 

  sudo apt update --fix-missing -y &&

  sudo apt install -y libmysqlclient21

sudo apt install -y gdal-bin

2)

%sh

sudo apt --fix-missing -y update --fix-missing

sudo apt-get install -y libudunits2-dev libproj-dev libgeos-dev libgdal-dev

View solution in original post

3 REPLIES 3

Debayan
Esteemed Contributor III
Esteemed Contributor III

Hi, receiving this message means that the package was not installed. There can be different reasons why this happens, which means there are also different ways to fix this. The most common cause when installing the required package is the existence of unresolved dependencies. Could you please check the same?

Please tag @Debayan​ with your next comment so that I will get notified. Thank you!

ArturoNuor
New Contributor III

Hi @Debayan Mukherjee​ thanks for your reply, here are my R/Databricks details and the 3 main libraries and errors i am encountering:

      

platform    x86_64-pc-linux-gnu          

version.string R version 4.1.3 (2022-03-10)

Runtime

11.3.x-scala2.12

11.3 LTS (includes Apache Spark 3.3.0, Scala 2.12)

gdal

%r

install.packages("gdal", repos = "http://cran.us.r-project.org")

Installing package into ‘/local_disk0/.ephemeral_nfs/envs/rEnv-93f5aa20-8204-42c9-b813-cda1cb27ae08’

(as ‘lib’ is unspecified)

Warning: package ‘gdal’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,

see the ideas at

https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

terra

%r

install.packages("terra", repos = "http://cran.us.r-project.org")

* installing *source* package ‘terra’ ...

** package ‘terra’ successfully unpacked and MD5 sums checked

** using staged installation

configure: CC: gcc

configure: CXX: g++ -std=gnu++14

checking for gdal-config... no

no

configure: error: gdal-config not found or not executable.

ERROR: configuration failed for package ‘terra’

* removing ‘/local_disk0/.ephemeral_nfs/envs/rEnv-93f5aa20-8204-42c9-b813-cda1cb27ae08/terra’

Installing package into ‘/local_disk0/.ephemeral_nfs/envs/rEnv-93f5aa20-8204-42c9-b813-cda1cb27ae08’

(as ‘lib’ is unspecified)

trying URL 'http://cran.us.r-project.org/src/contrib/terra_1.7-29.tar.gz'

Content type 'application/x-gzip' length 806064 bytes (787 KB)

==================================================

downloaded 787 KB

Warning in utils::install.packages(pkgs, ...) :

 installation of package ‘terra’ had non-zero exit status

The downloaded source packages are in

‘/tmp/RtmpPqEEXP/downloaded_packages’

raster

%r

install.packages("raster", repos = "http://cran.us.r-project.org")

* installing *source* package ‘terra’ ...

** package ‘terra’ successfully unpacked and MD5 sums checked

** using staged installation

configure: CC: gcc

configure: CXX: g++ -std=gnu++14

checking for gdal-config... no

no

configure: error: gdal-config not found or not executable.

ERROR: configuration failed for package ‘terra’

* removing ‘/local_disk0/.ephemeral_nfs/envs/rEnv-93f5aa20-8204-42c9-b813-cda1cb27ae08/terra’

ERROR: dependency ‘terra’ is not available for package ‘raster’

* removing ‘/local_disk0/.ephemeral_nfs/envs/rEnv-93f5aa20-8204-42c9-b813-cda1cb27ae08/raster’

Installing package into ‘/local_disk0/.ephemeral_nfs/envs/rEnv-93f5aa20-8204-42c9-b813-cda1cb27ae08’

(as ‘lib’ is unspecified)

also installing the dependency ‘terra’

trying URL 'http://cran.us.r-project.org/src/contrib/terra_1.7-29.tar.gz'

Content type 'application/x-gzip' length 806064 bytes (787 KB)

==================================================

downloaded 787 KB

ArturoNuor
New Contributor III

For the next soul looking for an answer, I managed to solve the issue with the next 2 Init scripts, it gets tricky in the apt or apt-get, that was the issue, sometimes it did update, sometimes it didn't, making it possible to find libmysqlclient21.

1)

%sh

sudo rm -r /var/lib/apt/lists/* 

sudo apt clean && 

  sudo apt update --fix-missing -y &&

  sudo apt install -y libmysqlclient21

sudo apt install -y gdal-bin

2)

%sh

sudo apt --fix-missing -y update --fix-missing

sudo apt-get install -y libudunits2-dev libproj-dev libgeos-dev libgdal-dev

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.