# Add multiple kernels to jupyterlab

**URL:** <https://discourse.jupyter.org/t/add-multiple-kernels-to-jupyterlab/18235>\
**Category:** Zero to JupyterHub on Kubernetes\
**Created:** [March 2, 2023, 12:37pm UTC](https://discourse.jupyter.org/t/add-multiple-kernels-to-jupyterlab/18235 "2023-03-02T12:37:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Padma\_Priya\_M](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/padma_priya_m/32/9018_2.png) [@Padma\_Priya\_M](https://discourse.jupyter.org/u/Padma_Priya_M)\
**Post date:** [March 2, 2023, 12:37pm UTC](https://discourse.jupyter.org/t/add-multiple-kernels-to-jupyterlab/18235/1 "2023-03-02T12:37:47Z")

</div>

How to add a Conda environment to the list of available kernels in Jupyter Notebook or JupyterLab in zero to jupyterhub in kubernetes setup?

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [March 2, 2023, 2:40pm UTC](https://discourse.jupyter.org/t/add-multiple-kernels-to-jupyterlab/18235/2 "2023-03-02T14:40:59Z")

</div>

In most cases the singleuser server environment can be customised in the same way you’d customise a standalone JupyterLab environment. Since Z2JH uses containers you’d need to build a custom image with your extra kernels and configuration.

---

<div class="post-metadata">

**Author:** ![Padma\_Priya\_M](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/padma_priya_m/32/9018_2.png) [@Padma\_Priya\_M](https://discourse.jupyter.org/u/Padma_Priya_M)\
**Post date:** [March 3, 2023, 5:38am UTC](https://discourse.jupyter.org/t/add-multiple-kernels-to-jupyterlab/18235/3 "2023-03-03T05:38:07Z")

</div>

I have used the default config of jupyterhub. While the jupyterlab server gets loaded I see ‘jupyterhub/k8s-singleuser-sample’ this image gets pulled. On top of this image I build an image by installing conda and creating an env. But I see ‘conda not found’ error in the jupyterlab server. Can you confirm how to setup the conda in jupyterlab server.

**Dockerfile:**  
RUN apt-get update &&   
apt-get install -y build-essential &&   
apt-get install -y wget &&   
apt-get clean &&   
rm -rf /var/lib/apt/lists/\*

ENV CONDA\_DIR /opt/conda

RUN wget --quiet [https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86\_64.sh](https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh) -O ~/miniconda.sh &&   
/bin/bash ~/miniconda.sh -b -p /opt/conda -u &&   
rm ~/miniconda.sh &&   
echo “. /opt/conda/etc/profile.d/conda.sh” \>\> ~/.bashrc &&   
echo “conda activate base” \>\> ~/.bashrc &&   
/opt/conda/bin/conda init &&   
/opt/conda/bin/conda update -n base -c defaults conda &&   
/opt/conda/bin/conda create -n myenv python=3.9

ENV PATH=$CONDA\_DIR/bin:$PATH

**Error in jupyterlab:**

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/6/6824a541326b12bdf8db92119ed5e3e33ba85047.png)

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [March 3, 2023, 1:52pm UTC](https://discourse.jupyter.org/t/add-multiple-kernels-to-jupyterlab/18235/4 "2023-03-03T13:52:09Z")

</div>

I think it’ll be easier to use an image that already includes conda, such as [GitHub - jupyter/docker-stacks: Ready-to-run Docker images containing Jupyter applications](https://github.com/jupyter/docker-stacks/)

> **[Customizing User Environment](https://z2jh.jupyter.org/en/stable/jupyterhub/customizing/user-environment.html#choose-and-use-an-existing-docker-image)**
>
> This page contains instructions for common ways to enhance the user experience. For a list of all the configurable Helm chart options, see the Configuration Reference. The user environment is the s...

---

<div class="post-metadata">

**Author:** ![Padma\_Priya\_M](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/padma_priya_m/32/9018_2.png) [@Padma\_Priya\_M](https://discourse.jupyter.org/u/Padma_Priya_M)\
**Post date:** [March 9, 2023, 2:31pm UTC](https://discourse.jupyter.org/t/add-multiple-kernels-to-jupyterlab/18235/5 "2023-03-09T14:31:02Z")

</div>

```auto
FROM jupyter/scipy-notebook:latest

RUN conda create -n myenv3 -q
RUN source activate myenv3; pip install ipykernel; 
RUN python -m ipykernel install --user --name myenv3 --display-name "myenv3 from docker"

```

I used this dockerfile to create a conda environment and add it in the kernel. The conda environment is getting added in the location but it is not showing up on the kernel.

![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/0/07ba541a6731dd65c0d42a9a0538f7bbaf36097f.png)

 ![Screenshot (128)](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/5/5f3f17e9bbd69e47969d55d422a91bbbd6447057.png)

How should we add it in the kernel ?

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [March 13, 2023, 11:20pm UTC](https://discourse.jupyter.org/t/add-multiple-kernels-to-jupyterlab/18235/6 "2023-03-13T23:20:24Z")

</div>

The docker-stacks docs contain an example of adding a kernel in a new environment:  
[https://jupyter-docker-stacks.readthedocs.io/en/latest/using/recipes.html#add-a-custom-conda-environment-and-jupyter-kernel](https://jupyter-docker-stacks.readthedocs.io/en/latest/using/recipes.html#add-a-custom-conda-environment-and-jupyter-kernel)
