Activating Julia virtual environments

Viewed 849

I'm trying to figure out how Julia packages work since I like having containerized environments. I'm really struggling with it.

In python, I'd do something like conda create env --name ds to make an environment and then to install containerized packages I'd use conda activate ds; conda install <packages>.

I'm not having much success trying to get Julia to make a virtual environment.

From the Julia REPL I can type ] to go to package managers then I can create an enviornment with activate ds. From here I can add important packages add IJulia DataFrames Plots

At this point, my environment becomes actual folders which is good.

What I then don't know how to do is to activate my environment so that I can then run using IJulia; notebook()

From the REPL if I type activate ds it doesn't know what I'm talking about, even if I do cd("ds"); activate . it still doesn't know what I'm trying to do...

I looked at the docs and it seems to detail out how to manipulate packages but I haven't found anything helpful for actually running them.

1 Answers

You have to write activate ds (or activate . if you are already in the ds directory) in the package manager mode that is started with ] as you have commented.

Alternatively you can activate environments when you start Julia. Just write

julia --project=.

(if you are already in the ds directory).

Here https://github.com/bkamins/PyDataGlobal2020 you have a step by step example how to run things for a sample project.

A third option is to activate the environment via the package manager API e.g. like this

using Pkg
Pkg.activate(".")
Related