Fun fact: it’s possible to create a Python Conda environment that:

  1. Is shared by everone who accesses a shared space inside a SageMaker domain
  2. Persists even if your KernelGateway app gets stopped and restarted

Here are the steps:

mkdir -p ~/.conda/envs
conda create --yes -p ~/.conda/envs/custom
conda activate ~/.conda/envs/custom
conda install -y ipykernel
conda config --add envs_dirs ~/.conda/envs

This approach should also work for SageMaker Notebook Instances. Also here’s a blog post that explores this approach (and three others) for managing Python packages in SageMaker notebook environments.

Happy Coding!