2

Summary

  • Installed R kernel in Anaconda environment
  • Works with Anaconda's browser Jupyter notebook, but not VS Code.

Details

I am trying to set up VS Code to recognize my R kernel for use with Jupyter Notebooks. The steps I have followed are as follows:

  1. Create a new R environment (via the Anaconda interface... Rstudio works just fine).
  2. Using the command line interface with the above environment activated, ensure Jupyter is installed: conda install jupyter
  3. Install irkernel: conda install -c r r-irkernel
  4. Run R from command line and initialize irkernel:
R
> IRkernel::installspec()
  1. Open VS Code and create a new notebook. Select the R kernel that appears, and run a basic commannd in the first cell: file.path(getwd())

These follow the steps here, and in other Stackoverflow posts (here and here).

Unfortunately, I cannot get the kernel to work. The above code in item 5 results in the following error:

Failed to start the Kernel. 
The kernel died. Error: ... View Jupyter log for further details.

There is a copy of the log available here (should be visible to everyone). The notebook is available here (but is literally just the one line of code mentioned above).

My hypothesis is that IRkernel::installspec() installs the kernel in a different location than the conda environment. The kernel is installed in C:\Users\aaron\AppData\Roaming\jupyter\kernels\ir, while in VS Code the kernel selected is in C:\Users\aaron\.conda\envs\rstudio\lib\R\bin\x64\R (the environment name is rstudio).

However, when I open Jupyter notebook via the Anaconda interface (not VS Code... i.e. the browser version), everything works just fine. The same code (file.path(getwd())) returns the appropriate 'C:/Users/aaron'.

I am sure I have done something silly wrong, and appreciate your help in advance!

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Aaron Wolf
  • 337
  • 3
  • 13

0 Answers0