How do I install R packages on the SageMaker Notebook instance? - r

I tried to start a R notebook in Sagemaker and I typed
install.packages("disk.frame")
and it gave me the error
also installing the dependencies ‘listenv’, ‘dplyr’, ‘rlang’, ‘furrr’,
‘future.apply’, ‘fs’, ‘pryr’, ‘fst’, ‘globals’, ‘future’
Warning message in install.packages("disk.frame"):
“installation of package ‘rlang’ had non-zero exit status”
Warning message in install.packages("disk.frame"):
“installation of package ‘fs’ had non-zero exit status”
Warning message in install.packages("disk.frame"):
“installation of package ‘pryr’ had non-zero exit status”
Warning message in install.packages("disk.frame"):
“installation of package ‘fst’ had non-zero exit status”
Warning message in install.packages("disk.frame"):
“installation of package ‘dplyr’ had non-zero exit status”
Warning message in install.packages("disk.frame"):
“installation of package ‘disk.frame’ had non-zero exit status”
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
How do I install R packages on Sagemaker?

Thank you for using Amazon SageMaker.
This issue has been resolved and you should be able to install R packages using
install.packages("disk.frame")
or
install.packages("disk.frame", repo="https://cran.rstudio.com/")
I tested it and was able to successfully install the package with ouput
also installing the dependencies ‘listenv’, ‘benchmarkmeData’, ‘doParallel’, ‘bigassertr’, ‘bit’, ‘dplyr’, ‘rlang’, ‘furrr’, ‘future.apply’, ‘fs’, ‘pryr’, ‘fst’, ‘globals’, ‘future’, ‘benchmarkme’, ‘bigreadr’, ‘bit64’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

I think you just need to specify a repo. For example, setting the RStudio CRAN repo, I can install perfectly fine.
install.packages("disk.frame", repo="https://cran.rstudio.com/")

I have been getting the same error installing odbc on a sagemaker instance. I've tryed
remotes::install_github()
or
devtools::install_github()
and also:
install.packages('odbc', repo="https://cran.rstudio.com/")
and pretty much on every instance I get the same warning
“installation of package ‘odbc’ had non-zero exit status”Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
and if I try to call the package:
Error in library(odbc): there is no package called ‘odbc’
Traceback:
library(odbc)

I followed the instruction:
https://aws.amazon.com/blogs/machine-learning/creating-a-persistent-custom-r-environment-for-amazon-sagemaker/
And this code worked for me
system("conda install -n R -c conda-forge r-rjava")
Where r-rjava is the package name from Anaconda cloud. You can find the specific package name/version here: https://anaconda.org/

In SageMaker, click "File" > "New" > "Terminal".
In that terminal type conda install -c conda-forge r-disk.frame and push the Enter key.
If you need to install other R packages on SageMaker, search for them on https://anaconda.org/ where it will show you what to enter in the Terminal to download.

if you are still running in to the error, I found a way to get around it. Is very simple. I answered it in this other post, which I had already created. Sorry 'bout that:
Error installing RODBC or ODBC on a Sagemaker Jupyter NoteBook Instance

Related

package installation failed after installing R

I try to install the tidyverse and tidytext package in R and it gives me the following error
the message is similar in both I would like to know what is the cause and a possible solution
ERROR: dependencies ‘hunspell’, ‘tokenizers’ are not available for package ‘tidytext’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/tidytext’
Warning in install.packages :
installation of package ‘tidytext’ had non-zero exit status
was installed before R 4.0.0: please re-install it

Non-zero exit status in R Jupyter Notebook but not in R

I am receiving a non-zero exit status when trying to install ggpubr in my R Jupyter Notebook. I was having this same issue about 2 weeks ago when trying to install gglot2, which I kept fumbling around including changing the CRAN and the package eventually installed.
I think there may be an issue at installing the dependencies in Jupyter notebook. I went back to the previous notebook where I installed ggplot2 and tried to run that code to see whether ggplot2 would reinstall--it doesn't and now that also returns non-zero exit status. I don't understand why I was once able to eventually install ggplot2 and I no longer can and I cannot install ggpubr either.
Note I've been able to install both ggplot2 and ggpubr in R, so I think this may be a Jupyter Notebook issue. I am an absolute beginner with coding, so any help with this and advice is much appreciated!!
Using macOS Mojave 10.14.6
install.packages("ggpubr")
also installing the dependencies ‘nloptr’, ‘pbkrtest’, ‘lme4’, ‘car’, ‘rstatix’
Warning message in install.packages("ggpubr"): “installation of package ‘nloptr’ had non-zero exit status”
Warning message in install.packages("ggpubr"): “installation of package ‘lme4’ had non-zero exit status”
Warning message in install.packages("ggpubr"): “installation of package ‘pbkrtest’ had non-zero exit status”
Warning message in install.packages("ggpubr"): “installation of package ‘car’ had non-zero exit status”
Warning message in install.packages("ggpubr"): “installation of package ‘rstatix’ had non-zero exit status”
Warning message in install.packages("ggpubr"): “installation of package ‘ggpubr’ had non-zero exit status”
Updating HTML index of packages in '.Library' Making 'packages.html'
...done
I kept getting the non-zero exit status when trying to install packages with Jupyter notebook with R kernel and was failing because of multiple dependencies when wanting to install a package. I am not an expert in any of these so please forgive me if I make an error in explaining or if it is a non-issue for you but please feel free to comment to clear things out. I just want to share my success story so hopefully it can help someone else:
I am working on a MacBook Pro. Here are the information I get when I run R.version() on my jupyter notebook with R kernel:
$platform 'x86_64-conda_cos6-linux-gnu'
$arch 'x86_64'
$os 'linux-gnu'
$system 'x86_64, linux-gnu'
$language 'R'
$version.string 'R version 3.6.1 (2019-07-05)'
These are the steps to take to fix the issue:
Go to https://anaconda.org/
Search the package name that you are trying to install
Copy the one line that is given to install the package, it should be something like:
Conda install -c r r-caret
#conda install -c r r-package_name
NOTE: sometimes during installing packages, you’re asked whether or not you want to continue, so add --y at the end of the above statement to continue, so something like this
Conda install -c r r-caret --y (I will always add it just to be on the safe side)
Click on the new launcher (+ icon) to create a new notebook with PySpark (once opened it has .ipynp extension)
On the first cell paste the copied line from step 3 and run
Once done, restart the kernel on the current notebook
Restart the kernel on your other notebook with R kernel
Run library (package_name) on your notebook with R kernel (e.x. library(caret))

Install Package in Jupyter Notebook, Anaconda

I'm running R language with Jupyter Notebook using Anaconda via Environments - not R Studio.
I'm trying to install R packages but it gives me the following errors:
install.packages('agricolae', repos="http://cran.rstudio.com/")
also installing the dependencies ‘units’, ‘sf’, ‘spdep’
Warning message in install.packages("agricolae", repos = "http://cran.rstudio.com/"):
“installation of package ‘units’ had non-zero exit status”Warning message in install.packages("agricolae", repos = "http://cran.rstudio.com/"):
“installation of package ‘sf’ had non-zero exit status”Warning message in install.packages("agricolae", repos = "http://cran.rstudio.com/"):
“installation of package ‘spdep’ had non-zero exit status”Warning message in install.packages("agricolae", repos = "http://cran.rstudio.com/"):
“installation of package ‘agricolae’ had non-zero exit status”Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Then I try to load the library
library("agricolae")
Error in library("agricolae"): there is no package called ‘agricolae’
Traceback:
library("agricolae")
If I open with R Studio, I can make it work.
Does anybody know how to solve the issue on Jupyter Notebook?, I'm using macOs sierra 10.12.6.
Thank you very much

Install R package in Jupyter

I have been trying over the weekend to install mosaic, car and some other packages on an R kernel (3.4.2) in Jupyter Notebook running Ubuntu 16.04. I have tried install.packages('car', '/home/jayaramdas/anaconda3/lib/R/library/', repos='http://cran.us.r-project.org'): it returns:
also installing the dependency ‘pbkrtest’
Warning message in install.packages("car", "/home/jayaramdas/anaconda3/lib/R/library/", :
“installation of package ‘pbkrtest’ had non-zero exit status”Warning message in install.packages("car", "/home/jayaramdas/anaconda3/lib/R/library/", :
“installation of package ‘car’ had non-zero exit status”
I've tried installing it in the original R package and I get this:
Warning messages:
1: In install.packages("car", "/home/jayaramdas/anaconda3/lib/R/library/", :
installation of package ‘pbkrtest’ had non-zero exit status
2: In install.packages("car", "/home/jayaramdas/anaconda3/lib/R/library/", :
installation of package ‘car’ had non-zero exit status
I tried using Rstudio to install it, but it won't let me write the file. I also tried downloading the zip file for Ubuntu and it still gave the 'non-zero exiterror. Is this a usual problem that people have withcar` and other R packages? I am just trying to figure how to add some packages to my jupyter notebook.
You are on Ubuntu. You want to use a package manager (conda).
May I suggest you use the native one?
sudo apt-get install r-cran-car
will install car and all its dependencies. If not, file an Ubuntu bug report.
Similarly, you can get many more packages from Ubuntu: apt-cache search 'r-cran-*'. And once you consider the Rutter PPAs you have a large part of CRAN prebuilt.

R: Can't install certain packages

I noticed that I am unable to install a bunch of packages. It started then I was trying to install the package carat. I would get this long error.
ERROR: compilation failed for package ‘robustbase’
* removing ‘/Users/regiswengel/anaconda/lib/R/library/robustbase’
Warning in install.packages :
installation of package ‘robustbase’ had non-zero exit status
ERROR: dependency ‘robustbase’ is not available for package ‘ddalpha’
* removing ‘/Users/regiswengel/anaconda/lib/R/library/ddalpha’
Warning in install.packages :
installation of package ‘ddalpha’ had non-zero exit status
ERROR: dependency ‘ddalpha’ is not available for package ‘recipes’
* removing ‘/Users/regiswengel/anaconda/lib/R/library/recipes’
Warning in install.packages :
installation of package ‘recipes’ had non-zero exit status
ERROR: dependency ‘recipes’ is not available for package ‘caret’
* removing ‘/Users/regiswengel/anaconda/lib/R/library/caret’
Warning in install.packages :
installation of package ‘caret’ had non-zero exit status
installing the dependencies ‘robustbase’, ‘ddalpha’, ‘recipes’ individually beforehand doesn't work either.
I also noticed that I am unable to update the packages
cluster
glmnet
maps
PKI
a bunch of others
I'm currently using R version 3.3.2 and RStudio Version 1.0.136. I have been using R and RStudio for months and have never had an issues installing packages. I have done a bunch of searching on Google and Stack-overflow and found some solutions. None of them have worked for me.
The error in my output was
gfortran -fPIC -I/Users/UserName/anaconda/include -L/Users/UserName/anaconda/lib -c eigen.f -o eigen.o
make: gfortran: No such file or directory
I found this thread that provided me with the answer I needed.
OS X package installation depends on gfortran-4.8

Resources