使用AWS re:Post即您表示您同意 AWS re:Post 使用条款

Is there a way to install R libraries in SageMaker that receive a non-zero exit status?

0

Hi all, I'm having an issue with an R kernel/Jupyter notebook. I've come across two different libraries that result in the following error:

Warning message in install.packages("XML", repos = "https://cran.r-project.org"):
“installation of package ‘XML’ had non-zero exit status”Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

XML is the second package that I have run into this issue with. The other is rJava.

I found a workaround that could work if I had root access, which is installing via the command line in a terminal. Which involves commands such as:

yum install r-cran-rjava

However, I don't have root access and cannot install as I get the message "You need to be root to perform this command." So this workaround hasn't been possible.

After checking the documentation for rJava and XML, I am running the requirements for JDK and other system requirements in SageMaker. This issue wasn't reproducible on a local RStudio environment. XML is a dependency for multiple R libraries (as is rJava). Is there a way that I can still install these packages?

已提问 7 年前1519 查看次数
1 回答
0
已接受的回答

For Amazon SageMaker notebook Instances, you have the ability to assume root privileges, so instead of:

$ yum install r-cran-rjava

you can try:

$ sudo yum install r-cran-rjava

which will allow you to impersonate the superuser (ie. root) for that command 1

But I don't believe that package exists in the available repos (ie. may be valid for another distro of Linux, but does not appear to be available in the yum repos -- running yum search 'r-cran-rjava' returned no results 2)

Instead, from a prompt, install R + the necessary development files for later installation of R packages:

$ sudo yum install -y R-java-devel.x86_64

And finally, install the necessary XML libraries to support the XML package in R:

$ sudo yum install -y libxml2-devel 3

After which you can then open R (either as root user...)

$ sudo R

or personal/local user

$ R

and execute the package installation:

> install.packages("XML", repos = "https://cran.r-project.org")

EDITED TO FIX RJAVA PACKAGE INSTALLATION

It looks like the installation is requiring libgomp.spec/libgomp.a files, so you can first find that file:

$ sudo find / -iname libgomp.spec

which should be located at /usr/lib/gcc/x86_64-amazon-linux/4.8.5/libgomp.spec -- if so, you can manually create symlinks to fix this:

$ sudo ln -s /usr/lib/gcc/x86_64-amazon-linux/4.8.5/libgomp.spec /usr/lib64/
$ sudo ln -s /usr/lib/gcc/x86_64-amazon-linux/4.8.5/libgomp.a /usr/lib64/

If that ran correctly, you should now see both files in /usr/lib64 path:

$ ls /usr/lib64/libgomp*

Once confirmed, you can run the install.package('rJava') command.

已回答 7 年前
profile picture
专家
已审核 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则