Skip to content

Fix for R[write to console]: No package called tidyverse in notebook

It can be convenient to add R to Jupyter or VS Code Notebook. However, if you've installed R packages using RStudio, you might get an error when you try to use them in a Jupyter Notebook.

The problem

For example, you try to include the tidyverse package in your notebook:

library(tidyverse)

And you receive the following error:

R[write to console]: No package called ‘tidyverse’

This might be happening because you have multiple versions of R installed on your computer, and the version of R that Jupyter or VS Code Notebook is using is different from the version of R that you used to install the tidyverse package.

The fix

You probably want the R that's in RStudio to be the same one that Jupyer uses. To do this we need to overwrite the kernel that Jupyter uses.

The kernel is the connection between Jupyer and R. It's the thing that tells Jupyter how to run R code.

Run the code below in RStudio. It will take the R kernel that's in RStudio and overwrite the kernel that Jupyter uses:

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

Problem solved!

Someday you might want to remove the old kernel that Jupyter was using, but you'll be fine for now...