1 minute read

I wanted to use Julia on computing clusters with Jupyterhub at LMU. So I first checked if Julia is installed using:

pip show julia

which gave me the info about the installed Julia. But when I run:

julia

This returned:

-bash: julia: command not found

and didn’t activate Julia. So I searched for this issue and got what I want from the website here.1

One should use the commands below:

module avail julia

which will show available Julia versions with their path. Then run:

module load julia/1.x.x # version you want
julia # type julia

will start the Julia interactive session.

Install Julia kernel for JupyterNotebook

julia> # start package manager by pressing ] key
(@v1.10) pkg> add IJulia
(@v1.10) pkg> # leave package manager by pressing backspace/delete
julia> using IJulia
julia> installkernel("Julia")

Work with Environment2

This is similar to creating python virtualenv which is necessary for working with your own projects and environments on clusters.

When you first creat a project/env:

(@v1.10) pkg> activate <YourProject>
(YourProject) pkg> st
    Status `~/YourProject/Project.toml` (empty project)
(YourProject) pkg> add Plots # add pkgs you want
(YourProject) pkg> activate  # leave the environment, then you go back to the default environment
(@v1.10) pkg>

When you already have the project/env3:

cd <YourPathToYourProject>/<YourProject>
julia --project=.
julia> # press ]
(YourProject) pkg>

or:

julia
julia> # press ;
shell> cd <YourPathToYourProject>/<YourProject>
shell> # press backspace and then press ]
(@v1.10) pkg> activate .
(YourProject) pkg>

Add an additional Julia kernel4

(YourProject) pkg>
julia> IJulia.installkernel("Julia YourProjectEnv", "--project=$(Base.active_project())")

The Launcher now has a new icon for starting a new jupyter notebook with “Julia YourProjectEnv”.

  1. https://researchcomputing.princeton.edu/support/knowledge-base/julia 

  2. https://pkgdocs.julialang.org/v1/environments/ 

  3. https://towardsdatascience.com/how-to-setup-project-environments-in-julia-ec8ae73afe9c 

  4. https://julialang.github.io/IJulia.jl/stable/manual/usage/