How to create additional kernels from script?

Hi, I’m trying to add an additional kernel, based on an additional virtual environment, but I can’t.

Below is the code I have inserted in my dockerfile.

# Dockerfile
FROM jupyter/minimal-notebook
WORKDIR /home/jovyan
USER root

ARG VENVS_PATH="/opt/envs"

RUN python -m venv --copies ${VENVS_PATH}/Kernel1
RUN . ${VENVS_PATH}/Kernel1/bin/activate \
    && pip install jupyter ipykernel numpy \
    && python -m ipykernel install --name "Kernel1" --user

OUTCOME:

  • :white_check_mark: Jupyter kernelspec list confirms me the presence of Kernel1.
  • :white_check_mark: I see Kernel1 as a new label among the available kernels, in the UI.
  • :x: I do NOT find numpy when I use Kernel1.

What am I doing wrong?

Answered here python - How to install a new Jupyter Kernel from script - Stack Overflow

1 Like