- Decide on a Julia home (I use
${XDG_DATA_HOME}/julia
) - Set up an environment variable (
export JULIA_HOME="${XDG_DATA_HOME}/julia"
) - Download Julia and extract it to
${JULIA_HOME}/julia-X.X
(eg.${JULIA_HOME}/julia-1.4
) - Repeat previous step for all desired Julia versions
- Place
julia-utilities.sh
somewhere on your system (eg.~/julia-utilties.sh
) - In your shell config, make sure to source the file (eg.
source ~/julia-utilities.sh
)
To access an installed julia version, simply use jl <version>
$ jl 1.4
Note: Visual Studio Code looks for a julia
executable in the path to run Julia, so this will not work with VS Code as I have set it up. For me personally, I have decided to only use VS Code when in a sandboxed environment, and that functionality does work because it adds the virtual environment's julia
binary to the path.
Make sure to have VirtualEnv.jl
installed in the base julia
installations
cd
into the desired location of the virtual environment- Run
jlenv <version> <env_name>
to create an empty environment:jlenv 1.4 env
(If no<env_name>
specified,env
is the default) - Call
jlactivate <env_name>
to activate the desired environment:jlactivate env
(If no<env_name>
specified,env
is the default) - Now running
julia
or simplyjl
will run the virtual environment's instance of Julia - At any time run
deactivate
to deactivate the environment
If you have a lot of packages that are commonly used, the jlsetup
function in julia-utilities.sh
helps automate setting up a new environment, and the jlenvsetup
function automates creating the environment, activating it, and calling setup.
jlpkginstall
is a useful function for installing the jlpkg
command line package manager for Julia into your Virtual Environments. Then, after activating a given environment, you can use the jlpkg
command to manage packages without having to open a Julia REPL.
- Install
IJulia
into the base julia installations (eg.jlp 1.4 add IJulia
) - Install the base Jupyter Kernel (eg.
jlkern 1.4
) - This installs the kernel named
Julia-Base-X.X
- Start Jupyer lab (eg.
jupyter lab
)
Note: IJulia
automatically installs kernels to Julia-X.X
upon installation, but because while using sandboxed virtual environments, you may have multiple installs of IJulia
, it will keep overwriting the Julia-X.X
kernel. This is default behavior that currently cannot be disabled.
- Create and activate a virtual environment (eg.
jlenv && jlactivate
) - Make sure
IJulia
is installed in the environment (eg.jlpkg add IJulia
) - Install the Jupyter Kernel (eg.
jlkern
) - This installs the kernel named
Julia-ENVIRONMENT_NAME-X.X
Make a test directory and cd into it
$ mkdir TEST && cd TEST
Creates a new julia virtual environment, activates it, and installs base packages
This is the same as running: jlenv 1.4 && jlactivate && jlsetup
$ jlenvsetup 1.4
Add packages to env project to be built into a system image using jlsyspkg alias
Here, jlsyspkg = jlpkg --project=${VIRTUAL_ENV} ...
$ jlsyspkg add Plots, DifferentialEquations
Build a system image for the current virtual environment
$ jlbuildsysimage
Start Julia using the system image for the current virtual environment
$ jlsys
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.4.2 (2020-05-23)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using Plots
julia> using DifferentialEquations
julia>
Create a Jupyter kernel for the virtual environment
$ jlkern
Create a Jupyter kernel for the virtual environment that uses the system image
$ jlsyskern
Deactivate virtual environment
$ deactivate