The main thing is that the user environment at /opt/tljh/user
is a conda env, so you can use sudo /opt/tljh/user/bin/conda
to perform operations that will be shared by users.
Is this possible?
Yes, indeed, you can do this. Once things are set up, you can create environments, e.g.
(e.g. creating new shared envs):
sudo /opt/tljh/user/bin/conda create -n env-name python=3.10 ipykernel [more packages]
To make it a kernel, you need to make sure the ipykernel
package is in the env (assuming you are making envs for Python kernels, otherwise you need whatever kernel package you are using).
The next step is to make the kernels in each env available to the user
env.
You have two options, generally:
-
manually, explicitly, for each env:
sudo /opt/tljh/user/envs/env-name/bin/python3 -m ipykernel install --name "env-name" --display-name "Env Name in UI" --prefix /opt/tljh/user
where:
name
is the internal key (the directory name) for the kernel spec (should be a short, simple string)display-name
is the human-friendly label you see in the UI, e.g.
--prefix
is the environment where the kernel should be available (i.e. the default user environment)
-
use something like nb_conda_kernels to automatically locate any conda environments and create kernelspecs for them, though that is largely unmaintained, and seems to have some compatibility issues at this point.
This process is the same for Python virtualenvs or any other environment installation of your choice. The main thing if you are creating a shared environment is the fileystem permissions - users should have read-execute permissions on the env (this should be the default if you create it with sudo conda create
, but may not be for every possible way to create an env).