<jupyter_start><jupyter_text>Creating your own conda environmentBy default when installing conda packages on Pangeo they are installed into the `root` environment.The downside of this is the environment is part of the docker image and any changes will be lost when stopping and starting your notebook server.This notebook sets up a custom conda environment in your home directory and allows you to persist your installed packages.  Create conda environmentFirst we need to create a new conda environment in your home directory which is a clone of the `root` environment.<jupyter_code>! conda create --clone root -p ~/.local/share/conda/envs/myenv -m<jupyter_output><empty_output><jupyter_text>In this command we are creating a new environment. We are specifying that we want to `--clone` the `root` environment. We are telling conda with `-p` to install it in our home directory at `~/.local/share/conda/envs/myenv` and to create that directory if it doesn't exist with `-m`.  Install kernelNext we need to create a new Jupyter Kernel which points to your custom conda environment. This allows you to select your custom environment when creating your notebooks.<jupyter_code>!! source activate /home/jovyan/.local/share/conda/envs/myenv && \
   python -m ipykernel install --user --name myenv --display-name "Python (myenv)"<jupyter_output><empty_output><jupyter_text>We start here by activating our new conda environment. This only works in a `bash` shell hence the double bang `!!`. We are then using `ipykernel` to create a new kernelspec config in your home directory using the conda environment `myenv` with the name `Python (myenv)`.  Adding packagesSadly when running an `sh` or `bash` cell in Jupyter a new subshell is created. This means it will pick up the default conda environment which may not be the environment being used by your kernel.Therefore in order to install packages you need to specify the environment name in your command.<jupyter_code>! conda install -n myenv boto3 -y<jupyter_output>Fetching package metadata .............
Solving package specifications: .

Package plan for installation in environment /home/jovyan/.local/share/conda/envs/myenv:

The following packages will be UPDATED:

    blas:     1.0-noblas conda-forge --> 1.0-mkl      defaults   
    boto3:    1.6.6-py_0 conda-forge --> 1.7.24-py_0  conda-forge
    botocore: 1.9.6-py_0 conda-forge --> 1.10.24-py_0 conda-forge

blas-1.0-mkl.t 100% |################################| Time: 0:00:00   8.03 MB/s
botocore-1.10. 100% |################################| Time: 0:00:01   1.98 MB/s
boto3-1.7.24-p 100% |################################| Time: 0:00:00  46.33 MB/s
{'fraction_non_alphanumeric': 0.11738148984198646, 'fraction_numerical': 0.025959367945823927, 'mean_word_length': 4.2445759368836296, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '19117', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 820, 'n_tokens_neox': 761, 'n_words': 333, 'path': '3.0 Advanced/3.0.1 Creating Persistent Conda Environments.ipynb', 'repo_name': 'met-office-lab/example-notebooks', 'size': '2658'}