3

I just started using Julia and want to use different environments. So far, I have two environments in two different folders, both with IJulia added to them and then different other packages. When starting Jupyter however, I only see one Julia version as a kernel (Julia 1.5.3).

For Python environments, I use nb_conda_kernels, so Jupyter displays Python[conda env:root], Python[conda env:myEnv], etc. How do I achieve the same with Julia, so i can switch Kernels without switching directories and restarting Jupyter from a different directory?

seulberg1
  • 955
  • 1
  • 7
  • 19
  • [This answer](https://stackoverflow.com/questions/60406075/how-to-set-julia-environment-for-ijulia-jupyter-notebook) shows that the default IJulia kernel is set to `--project=@.`, so you just need to launch IJulia from within a specific folder to get it to recognize that environment. – Vivek Apr 05 '22 at 15:24

1 Answers1

1

Since IJulia is using Python you can just install nb_conda_kernels for your Julia installation:

using PyCall, Conda
Conda.add("nb_conda_kernels")

Now you can use the Julia-inbuilt Python to execute any command you need. For an example:

julia> run(`$(PyCall.python) -m nb_conda_kernels list`)
[ListKernelSpecs] WARNING | Config option `kernel_spec_manager_class` not recognized by `ListKernelSpecs`.
[ListKernelSpecs] [nb_conda_kernels] enabled, 4 kernels found
Available kernels:
  conda-root-py           c:\juliapkg\julia-1.6.0-beta1\conda\3\share\jupyter\kernels\python3
  conda-env-3-py          c:\juliapkg\julia1.5.3\conda\3\share\jupyter\kernels\python3
  conda-env-3-2-py        c:\juliapkg\julia1.5.3\conda\3\share\jupyter\kernels\python3
  conda-env-Anaconda3-py  c:\programdata\anaconda3\share\jupyter\kernels\python3
  julia-1.5               C:\Users\pszufe\AppData\Roaming\jupyter\kernels\julia-1.5
  julia-1.6               C:\Users\pszufe\AppData\Roaming\jupyter\kernels\julia-1.6
  julia-o3-1.5            C:\Users\pszufe\AppData\Roaming\jupyter\kernels\julia-o3-1.5
  python3                 C:\JuliaPkg\Julia-1.6.0-beta1\conda\3\share\jupyter\kernels\python3
Process(`'C:\JuliaPkg\Julia-1.6.0-beta1\conda\3\python.exe' -m nb_conda_kernels list`, ProcessExited(0))
Przemyslaw Szufel
  • 40,002
  • 3
  • 32
  • 62
  • So, I did what you suggested and in the process it created a new conda python environment, which I see, but I still can only see one Julia environment (and not the two that I created). I am using the "standard" approach from the Julia documentation: https://julialang.github.io/Pkg.jl/v1.1/environments/. Is it, the case that because Julia's pkg manager does not require to reinstall Julia for every environment that they simply would not show up as separate? – seulberg1 Jan 12 '21 at 01:24
  • I believe this will show whatever is defined in %APPDATA%\jupyter\kernels so this is where you should look at. – Przemyslaw Szufel Jan 12 '21 at 17:14