How to use different versions of R kernels in VS code Jupyter notebooks when using Linux
You can add any number of custom kernels to the folder ~/.local/share/jupyter/kernels
If you already have one R kernel installed and working, there should be an 'r' folder already in this directory containing a kernel.json
file with the following content:
{"argv": ["/usr/lib/R/bin/R", "--slave", "-e", "IRkernel::main()", "--args", "{connection_file}"],
"display_name":"R",
"language":"R"
}
This allows this kernel to be available through the top right kernel options in VS code and you can add more by adding new folders to this directory (one per new kernel) with a corresponding kernel.json
file inside. See more about adding kernels here. For example creating a new 'r3.6.3' folder with a new kernel.json
containing:
{"argv": [".renv/versions/3.6.3/bin/R", "--slave", "-e", "IRkernel::main()", "--args", "{connection_file}"],
"display_name":"R 3.6.3",
"language":"R"
}
will add this version of the kernel to the options available. Notice that you only need to specify the path location of the kernel version wherever you have it installed.
Also notice I'm using the library renv
to manage various versions of R. If you don't want to create various folders for different kernels each time, you can combine renv
to handle multiple versions of R and make sure the file does not point to any particular version but simply invokes R,
{"argv": ["R", "--slave", "-e", "IRkernel::main()", "--args", "{connection_file}"],
"display_name":"R renv",
"language":"R"
}
which will trigger VS code to use whatever version of R you are using at that moment via renv
. See here for more on the latter library
Failed to start the Kernel - Jupyter in VS Code
Could you try to reinstall the pyzmq
module?
pip uninstall pyzmq
pip install pyzmq==19.0.2
Integrating Python and Jupyter Notebook with Visual Studio Code
I discovered a very simple answer: I installed the VSC package in the official Snap repo.
VSC and Python-Jupyter look to be all playing nice together now:
jupyter server : not started, no kernel in vs code
I had exactly the same problem when I installed Visual Studio Code and tried to run some Python code from a jupyter notebook on my fresh Ubuntu 18.04.
How I solved it:
1) Press Command+Shift+P
to open a new command pallete
2) Type >Python: Select Intepreter to start jupyter notebook server
3) Open the notebook again
And it worked fine. Hope it works for you.
Related Topics
Cannot Install Library(Xlsx) in R and Look for an Alternative
"Non-Finite Function Value" When Using Integrate() in R
R: Split String into Numeric and Return the Mean as a New Column in a Data Frame
Grouping Factor Levels in a Data.Table
R Geom_Tile Ggplot2 What Kind of Stat Is Applied
Data.Table: Sum by All Existing Combinations in Table
How to Draw Roc Curve Using Value of Confusion Matrix
How to Color Bar Plots When Using ..Prop.. in Ggplot
R - Identify Consecutive Sequences
Remove the Columns with the Colsums=0
Removing Everything After First 'Backslash' in a String