We will be using Evcxr Jupyter Kernel for the Rust programming language.
Installation
-
Make sure Rust and Jupyter is installed. Run
rustc --versionto verify Rust installation. Runjupyter --helpto verify Jupyter installation. -
Build the kernel from source by running:
cargo install --locked evcxr_jupyterThis command will place the executable at
~/.cargo/bin/evcxr_jupyter. -
Run this command to verify if executable can reached through
$PATH:which evcxr_jupyterIf nothing could be found, make sure to add
export PATH="$HOME/.cargo/bin:$PATH"in the shell file (e.g.~/.zshrc). -
Run the following command in order to register the kernel with Jupyter:
evcxr_jupyter --installBy default, the above command will install the kernel into a user local directory, e.g.,Â
$HOME/.local/share/jupyter/kernels. But in my case (on macOS), it wrote the files in this path~/Library/Jupyter/kernels/rust. (Path will be shown in the terminal as well when you run above command) -
We also need the source for the Rust standard library installed. We can confirm if it already installed or not using:
rustup component list --installed | grep rust-srOtherwise, install using the following command:
rustup component add rust-src -
We can verify kernel registration using the following command:
jupyter kernelspec list | grep rustIt will show
rust. -
Start Jupyter Notebook using:
jupyter notebookOnce started, it should open a page in your web browser. Look for the “New” menu on the right and from it, select “Rust”.
Uninstallation
evcxr_jupyter --uninstall
cargo uninstall evcxr_jupyterYou can check the latest README for more details.
