shreenidhi ks
shreenidhi ks

Reputation: 11

Unable to install RGLPK in Databricks R Notebook

I have the below problem with installing an R Package.

Context: I am working on a optimization problem and i have to use RGLPK package for the required functionalities of linear programming.

This is what I tried:

  1. Installing package using install.package (error was on GLPK Dependencies)

  2. Tried loading RGLPK File manually into library and installing, got error.

  3. followed step in this link- "GLPK: No such file or directory error when trying to install R package"

it throws an error saying "Rglpk.h:1:18: fatal error: glpk.h: No such file or directory"

Tried lot of other google/stack overflow methods and was not successful.

seeking help from this community and any advise would be greatly appreciated.

Upvotes: 0

Views: 651

Answers (1)

shreenidhi ks
shreenidhi ks

Reputation: 11

I have finally found the answer through some R&D. Posting here hoping it may help someone in future.

Operating system of Databricks ​is Ubuntu and it requires few dependencies like GLPK,Slam etc.

Slam could be installed easily but GLPK dependency was the main challenge. I did checke in various forums on installing GLPK in ubuntu and majorly all were suggesting installing using sudo command like below:

sudo apt-get install glpk-utils libglpk-dev But it was not installing and stuck in one place for more then 3 hours. Then i installed in my local ubuntu to understand the flow and noticed that since sudo apt install command was meant for interactive installation, it requires user to enter Yes couple of time. But Databricks shell terminal is not a interactive window and hence it required a command to force Yes all the time and below is the working command for that:

%sh

sudo apt-get install -y glpk-utils libglpk-dev

Post this you can use install.packages("Rglpk") and it will work like a charm :) above process can be followed for all non cran packages in Databricks.

Upvotes: 1

Related Questions