One Jupyter - Three Languages
How to setup JupyterLab for Python, R and Julia.
I use Python for my coding work usually and R occasionally. And I’m currently learning Julia. Spyder (for Python), Juno (for Julia) and RStudio (obviously for R) were my usual editors. But now I use Jupyter for all three languages. So I would like to explain the process of integrating R and Julia into JupyterLab because Python is the default in Jupyter.
I use elementary OS. Thus Python 3 comes pre-installed. Otherwise you have to install Python along with pip and need to add both binaries’ locations to PATH. Following things are for Gnu/Linux distributions based on Ubuntu/Debian. Change commands to your system accordingly.
Install JupyterLab
JupyterLab can be installed using pip:
$ sudo pip3 install jupyterlab
Running jupyterlab
in terminal will open JupyterLab in a browser window.
Install R & Support for Jupyter
R binaries for Gnu/Linux, Windows & Mac are available at CRAN. Download and install R. Add the installation path to PATH if required.
For Gnu/Linux distros, there is a better way.
- Add GPG key:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
- Add R repo:
$ sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/'
If you are not using bionic (Ubuntu 18.04), change the above code according to your version. - Update repos and install R:
$ sudo apt update && sudo apt install r-base
Setting Up Jupyter for R
Running R
in terminal, will open R interactive shell. But if you are using Gnu/Linux, you have to do sudo R
to install packages. Anyway, open R shell. Then:
- Install IRkernel:
> install.packages('IRkernel')
- Make the kernel available to Jupyter:
> IRkernel::installspec(user = FALSE)
Settinguser=TRUE
will limit installation only for the current user. After doing these, Jupyter can be used to create R notebooks.
Install and Set Up Julia
Julia binaries are available at julialang.org. For Gnu/Linux, don’t use snap as it provides older version. Julia shows significant changes over versions. After installation/extraction, add Julia executable to PATH.
Install & Set Up IJulia
IJulia provides Jupyter support to Julia. To install IJulia, open Julia by typing julia
in shell. Switch to Pkg mode by hitting ]
.
(@v1.5) pkg> add IJulia
After installation, to make Julia available in Jupyter, build IJulia.
(@v1.5) pkg> build IJulia
So Jupyter is ready to use with Python, R and Julia.