Checking for non-preferred file/folder path names (may take a long time depending on the number of files/folders) ...

Scripts to Create Conda Environments in JupyterHub


An older version of this resource http://www.hydroshare.org/resource/3707b6474396455fb69c28ba58da37c0 is available.
Authors:
Owners: This resource does not have an owner who is an active HydroShare user. Contact CUAHSI (help@cuahsi.org) for information on this resource.
Type: Resource
Storage: The size of this resource is 29.4 KB
Created: Jul 28, 2025 at 7:24 p.m. (UTC)
Last updated: Jul 28, 2025 at 10:51 p.m. (UTC)
Citation: See how to cite this resource
Sharing Status: Public
Views: 94
Downloads: 0
+1 Votes: Be the first one to 
 this.
Comments: No comments (yet)

Abstract

This resource contains the following Bash script which can be used by the user in any of the JupyterHub instances accessible via the "Open with" functionality of HydroShare to create a custom Conda environment to run AORC related notebooks. In order to run this Bash script files in JupyterHub, first make the file executable using the JupyterHub terminal as shown below:

chmod +x setup_aorc_jupyterhub_conda_env.sh

Then the above script can be executed from the command line as follows:

./setup_aorc_jupyterhub_conda_env.sh

NOTE: The notebook (CondaEnvironmentSetup.ipynb) available in this resource also can be used for creating the 'aorc' Conda environment if you prefer not to use the terminal.

After executing the script, it will create a new Conda environment called 'aorc'. It will also register this new Conda environment as a new Jupyter kernel. Though the script creates a new kernel and names it as 'Python3 (AORC)'', the conda environment by default also registers the 'aorc' environment as a new kernel with the name of 'Python [conda env:aorc]' or 'Python [conda env:.conda-aorc]'. In order for any of the AORC related notebooks to use this new kernel you have to first shut down all kernels and then use the option 'Change Kernel" to select this new kernel. Depending on the JupyterHub instance that you are using, you have to select a specific kernel name as described below:

- 2i2c JupyterHub: Select kernel 'Python [conda env:.conda-aorc]'. In the list of kernels, you may see 'Python3 (AORC)'. Don't select this kernel!
- CyberGIS JupyterHub: Select kernel 'Python3 (AORC)'
- CUAHSI JupyterHub: Select kernel 'Python [conda env:aorc]'. In the list of kernels, you may see 'Python3 (AORC)'. Don't select this kernel!

This resource also contain this yml file:

- environment.yml (This file contains the python modules needed to run the AORC notebooks - similar to requirements.txt file used with pip install). The above Bash script file uses this yml file to install the python modules listed in that file.

- delete_aorc_jupyterhub_conda_env.sh (This script can be run to delete the 'aorc' Conda env. Note this file needs to be first set as an executable file - chmod +x delete_aorc_jupyterhub_conda_env.sh)

- sample_commands_to_create_conda_env_jh.md (This file contains example commands to create a new Conda environment - without using a bash script)

How to use the new kernel created by the script (see above)?
If you just created the new aorc Conda environment, shut down all kernels. Open the notebook that needs to use the aorc Conda environment. Change the kernel for the notebook to aorc kernel. (for the exact name of the kernel see above).

How to update the aorc Conda environment after it has been created?
Update here means installing additional python modules or upgrading to a newer version of any modules that is already installed in the aorc conda environment.

- Update the environment.yml file by adding new modules or updating the version of any modules in that file.

- In the JupyterHub instance, use a terminal and run the following 2 commands:

- conda activate aorc
- mamba env update -f environment.yml

If you just want to install few new modules or upgrade existing modules without updating environment, then run (after activating the aorc env):

conda install <module-1-name> <module-2-name>
OR
pip install <module-1-name> <module-2-name>

NOTE: It is better to update the environment yml file when there is a need to update the environment as it helps reproducibility.

Subject Keywords

Content

README.md

AORC Conda Environment Setup Scripts

This resource contains bash scripts for managing Conda environments to run AORC-related notebooks in various JupyterHub instances accessible via HydroShare's "Open with" functionality.

Usage Instructions

To use any of the Bash scripts, first make them executable using the JupyterHub terminal:

chmod +x setup_aorc_jupyterhub_conda_env.sh

Then execute the script:

./setup_aorc_jupyterhub_conda_env.sh

Available Scripts

Environment Setup Scripts

  • setup_aorc_jupyterhub_conda_env.sh - Creates a new Conda environment 'aorc' in CUAHSI JupyterHub

Environment Cleanup Scripts

  • delete_aorc_jupyterhub_conda_env.sh - Deletes the 'aorc' Conda environment in CUAHSI JupyterHub

Configuration Files

  • environment.yml - Contains python modules for AORC notebooks (used by CUAHSI and CyberGIS scripts)

Updating the 'aorc' Conda Environment

  1. Update the environment.yml file with new modules or version changes
  2. Run the following commands in the JupyterHub terminal:

conda activate aorc

mamba env update -f environment.yml

Quick Updates Without File Modifications

First activate the 'aorc' Conda environment:

conda activate aorc

You can directly install or upgrade modules using:

conda install <module-1-name> <module-2-name>

OR

pip install <module-1-name> <module-2-name>

Sample Commands for Creating Conda Environment

  • sample_commands_to_create_conda_env_jh.md - Example commands for manual Conda environment creation

Note: For better reproducibility, it's recommended to update the environment.yml file when making changes to the environment.

Related Resources

This resource updates and replaces a previous version Dash, P. (2025). Scripts to Create Conda Environments in JupyterHub, HydroShare, http://www.hydroshare.org/resource/3707b6474396455fb69c28ba58da37c0

How to Cite

Dash, P. (2025). Scripts to Create Conda Environments in JupyterHub, HydroShare, http://www.hydroshare.org/resource/ece5940aa7cf4f50bd4b64e3f0051fce

This resource is shared under the Creative Commons Attribution CC BY.

http://creativecommons.org/licenses/by/4.0/
CC-BY

Comments

There are currently no comments

New Comment

required