Create a condo environment on JupyterHub and add it to JupyterHub

From Manu and Loh Lab Wiki
Jump to navigation Jump to search

Setting up the environment

  • In the JupyterLab launcher, click "Terminal" to launch the terminal.
  • Change working directory to directory where you will keep the environment definition.
cd <directory_with_environment_definition>
  • Create and edit the conda environment YAML description file to specify your environment. Make sure that it has ipykernel installed in it. For example
  
name: <your_environment_name>
channels:
  - bioconda
  - conda-forge
dependencies:
  - ipykernel
  - snakemake-minimal >=5.24.1
  - macs2 >=2.2.7.1
variables:
  PYTHONPATH:
Make sure to unset the PYTHONPATH environment variable as in the example above.
  • Activate the base conda environment
conda activate
  • Create a conda environment that contains the necessary tools, including jupyterlab
mamba env create --file <environment_description_file>.yaml
  • Confirm the creation by listing your conda environments
conda env list
and ensuring that an environment with the name <your_environment_name> has been created.

Add environment to JupyterHub

  • Make sure that your environment, besides the other things you need, also has ipykernel installed in it.
conda activate <your_environment_name>
conda list | grep ipykernel
  • If it does not contain ipykernel, it may be installed like so
mamba install ipykernel -n <your_environment_name>
  • Activate your environment
conda activate <your_environment_name>
  • Install the kernel
python -m ipykernel install --user –-name <your_environment_name> –-display-name “Python (<your_environment_name>)” --env PATH ~/.conda/envs/<your_environment_name>/bin:${PATH}
  • Reload the JupyterHub webpage in the browser to display the newly added kernel in your Launcher.