Commit 31568822 authored by Michael Pilosov's avatar Michael Pilosov Committed by GitHub

instructions for python 3.x kernels with conda

this was surprisingly hard to find help for online that was up-to-date and worked with the stacks, contributing here in hopes it'll help others.
parent cd158647
...@@ -98,6 +98,47 @@ USER $NB_USER ...@@ -98,6 +98,47 @@ USER $NB_USER
Ref: Ref:
[https://github.com/jupyter/docker-stacks/issues/440](https://github.com/jupyter/docker-stacks/issues/440) [https://github.com/jupyter/docker-stacks/issues/440](https://github.com/jupyter/docker-stacks/issues/440)
## Add a Python 3.x environment
The default version of Python that ships with conda/ubuntu may not be the version you want.
To add a conda environment with a different version and make it accessible to Jupyter, the instructions are very similar to Python 2.x but are slightly simpler (no need to switch to `root`):
```
# Choose your desired base image
FROM jupyter/minimal-notebook:latest
# name your environment and choose python 3.x version
ARG conda_env=python36
ARG py_ver=3.6
# you can add additional libraries you want conda to install by listing them below the first line and ending with "&& \"
RUN conda env create --quiet --yes -p $CONDA_DIR/envs/$conda_env python=$py_ver ipython ipykernel && \
conda clean --all -f -y
# alternatively, you can comment out the lines above and uncomment those below
# if you'd prefer to use a YAML file present in the docker build context
# COPY environment.yml /home/$NB_USER/tmp/
# RUN cd /home/$NB_USER/tmp/ && \
# conda env create -p $CONDA_DIR/envs/$conda_env -f environment.yml && \
# conda clean --all -f -y
# create Python 3.x environment and link it to jupyter
RUN $CONDA_DIR/envs/${conda_env}/bin/python -m ipykernel install --user --name=${conda_env} && \
fix-permissions $CONDA_DIR && \
fix-permissions /home/$NB_USER
# any additional pip installs can be added by uncommenting the following line
# RUN $CONDA_DIR/envs/${conda_env}/bin/pip install
# prepend conda environment to path
ENV PATH $CONDA_DIR/envs/${conda_env}/bin:$PATH
# if you want this environment to be the default one, uncomment the following line:
# ENV CONDA_DEFAULT_ENV ${conda_env}
```
## Run JupyterLab ## Run JupyterLab
JupyterLab is preinstalled as a notebook extension starting in tag JupyterLab is preinstalled as a notebook extension starting in tag
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment