mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-17 06:52:56 +00:00
Merge pull request #973 from mathematicalmichael/patch-1
instructions for python 3.x kernels with conda
This commit is contained in:
@@ -98,6 +98,47 @@ USER $NB_USER
|
||||
Ref:
|
||||
[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
|
||||
|
||||
JupyterLab is preinstalled as a notebook extension starting in tag
|
||||
|
Reference in New Issue
Block a user