22

I am trying to run R code in Jupyter and the R Kernel was added. Most of the time, packages can be installed successfully. However, some of the packages, such as RCurl and ggmap, would got error while installing.

Example:

install.packages("RCurl")

Warning message in install.packages("RCurl"): “installation of package ‘RCurl’ had non-zero exit status”Updating HTML index of packages in '.Library'

Making 'packages.html' ... done

What should I do?

1
  • 1
    I have the same problem just with "ggmap" Commented Jul 14, 2017 at 7:30

7 Answers 7

18

Try to specify CRAN as repository in your install.packages statement when installing RCurl and ggmap. For example:

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

This Stack Overflow post on installing R packages through Anaconda/Jupyter beyond those included in R essential provides more detail.

(Side note: I had encountered the same issue when trying to install R packages on computer clusters. This solution worked for me.)

1
  • It seems as though you can run this line directly from a Jupyter NB. (+1) Commented May 11, 2020 at 0:28
2

use conda comment:

conda install r-RCurl

2

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:

  1. Go to https://anaconda.org/

  2. 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)

  1. Click on the new launcher (+ icon) to create a new notebook with PySpark (once opened it has .ipynp extension)
  2. On the first cell paste the copied line from step 2 and run
  3. Once done, restart the kernel on the current notebook
  4. Restart the kernel on your other notebook with R kernel
  5. Run library(package_name) on your notebook with R kernel (e.x. library(caret))
0

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

This command will install the packagae in the conda "/home/user/anaconda3/lib/R/library" and use the cran r repository as source.

Add path in Anaconda
As per this answer, one can also add additional paths in anaconda to load libraries from (for eg., the location where R studio saves the user-installed packages) with
.libPaths( c( .libPaths(), "~/userLibrary") )

For example, the following worked for me:
In Anaconda :
.libPaths( c( .libPaths(), "C:\Users\name\Documents\R\win-library\3.5") )

When I tried to add anaconda's library path to RStudio, it resulted in errors (The procedure entry point MARK_NOT_MUTABLE could not be located in the dynamic link library << arose 4 times in succession) after installation of a package, though the package seemed to load.

Replace name with your local user folder name


Add/change path in RStudio
A useful link to make changes in default user-installed library paths :
https://www.accelebrate.com/library/how-to-articles/r-rstudio-library

To find out where a package has been installed:
find.package('package_name')

0

The directions nobody else supplied worked for me, but I found this guide, and it worked. Spent way too much time trying all these when I just needed a few simple commands. https://developers.refinitiv.com/en/article-catalog/article/setup-jupyter-notebook-r

I already had R and python installed, so I skipped to step 3. The only seems to mention windows, but it worked for me on mac as well. After following them I was able to install the packages using install.packages("dplyr", repos = "http://cran.us.r-project.org") in a cell in jupyter.

0

You have to create a directory in which your package will be and do for eg:

install.packages('ggplot2',loc='your directory')

0

First Step: You can install the IRkernel packages by running the following command in an R console:install.packages('IRkernel')

Second Step: You will have to make Jupyter see the newly installed R kernel by installing a kernel spec. To install system-wide, set user to False in the installspec command IRkernel::installspec(user = FALSE) Setup Jupyter Notebook for R

Not the answer you're looking for? Browse other questions tagged or ask your own question.