How to add Julia code to your Jupyter notebooks and also enable you to use Python and Julia simultaneously in the same notebook

Photo by Markus Spiske from Pexels

Julia is a really exciting high-level, high-performance, dynamic programming language. It has easy to understand syntax and is forecast to be one of the major programming languages for data science in the coming years.

Jupyter is a great multi-language IDE which I always use as my default environment to explore data with and also write preliminary code routines etc before porting my code to dedicated python scripts which are better for full production purposes for example inside a docker running on AWS etc.

In the below steps I explain how to install Julia and also how to add it as a kernel in Jupyter so you can effectively write Julia code in Jupyter.

I have also explained how you can use PyJulia to use Julia inside python notebooks. This additional option is powerful as you can use the best of both languages especially in terms of data exploration and data visualisations.

I have set out the steps as they should be completed stating any prerequisites first then installing Julia before explaining how to integrate Julia with Jupyter and concluding with detailing how you can mix and match Python and Julia code in the same notebook.

Prerequisites

It is important to note here I assume you are using a Linux distribution whether that is on a dedicated Linux machine or via WSL or a virtualBox is immaterial as long as you are using a Linux environment. In addition you should already have Jupyter installed and working on your local machine for coding etc.

Install Julia

First to do a basic install of the Julia language download the Julia tar from https://julialang.org/downloads/ making sure to take the stable version (currently 1.6.2)

Next simply untar the file in your terminal to get it ready for use.
tar -xvzf julia-x.y.z-linux-x86_64.tar.gz

Add Julia to the PATH variable by adding below line in your .zshrc file. This assumes you are using zsh as your shell however if you are using standard bash simply put the below line in your .bashrc file instead.
export PATH="$PATH:/path_to_julia_file/julia-1.0.5/bin"

Check if this is working by typing julia in the terminal and it should launch the Julia REPL (read-eval-print-loop) as shown below.

Image by Author

Add Julia Kernel to Jupyter

To add a Julia kernel to Jupyter we simply add the IJulia package.

In order to do this first launch the Julia REPL from your terminal like you…

Continue reading: https://towardsdatascience.com/how-to-best-use-julia-with-jupyter-82678a482677?source=rss—-7f60cf5620c9—4

Source: towardsdatascience.com