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


A newer version of this resource http://www.hydroshare.org/resource/ece5940aa7cf4f50bd4b64e3f0051fce is available that replaces this version.
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 33.7 KB
Created: May 30, 2025 at 1:58 p.m. (UTC)
Last updated: Jul 23, 2025 at 2:58 a.m. (UTC)
Citation: See how to cite this resource
Sharing Status: Public
Views: 994
Downloads: 31
+1 Votes: Be the first one to 
 this.
Comments: No comments (yet)

Abstract

This resource contains the following bash scripts which can be used by the user in any of the JupterHub instances accessible via the "Open with" functionality of HydroShare to create conda environment to run AORC related notebooks. In order to run any of the listed bash script files in JupyterHub, first make the file executable using the JupyterHub terminal. Here is an example:

chmod +x setup_aorc_conda_env_cuahsi_jh.sh

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

./setup_aorc_conda_env_cuahsi_jh.sh

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 with name 'Python [conda env:aorc]'. In order for any of the AORC related notebooks to use this kernel you have to first shut down all kernels and then use the option 'Change Kernel" to select this new kernel.

- setup_aorc_conda_env_cuahsi_jh.sh (This script should be used in CUAHSI JupyterHub to create a new conda environment called 'aorc'. The corresponding new kernel that is created will have name as 'Python [conda env:aorc]' )

- setup_aorc_conda_env_cybergis_jh.sh (This script should be used in CyberGIS Jupyter for Water) to create a new conda environment called 'aorc'. The corresponding new kernel that is created will have name as 'Python 3 (AORC)')

- 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 script files use this yml file to install the python modules listed in that file.

- delete_aorc_conda_env_cuahsi_jh.sh (This script can be run to delete the conda env 'aorc' in CUAHSI JupyterHub)

- delete_aorc_conda_env_cybergis_jh.sh (This script can be run to delete the conda env 'aorc' in CyberGIS Jupyter for Water)

- setup_aorc_conda_env_2i2c_jh.sh (This script should be used in 2i2c JupyterHub to create a new conda environment called 'aorc'. The corresponding new kernel that is created will have name as 'Python [conda env:.conda-aorc]')

- environment-2i2c.yml (This file is used in the above script that creates the aorc conda env in 2i2c. This environment file has few python modules for installing using conda)

- requirements-2i2c.txt (This file is used in the above script that creates the aorc conda env in 2i2c to pip install most of the python modules needed for AORC notebooks. The reason for using 'pip install' in case of 2i2c to install majority of python modules for the new conda environment is that 2i2c gives error 'no space left on device' if the modules are installed using 'conda'.)

- delete_aorc_conda_env_2i2c_jh.sh (This script can be run to delete the conda env 'aorc' in 2i2c JupyterHub)

- 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. The following commands are applicable to CUAHSI and CyberGIS JH instances.

- 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

Update aorc environment in 2i2c:
- conda activate aorc

If you have updated the environments-2i2c.yml, run
- conda env update -f environment-2i2c.yml

If you have updated the requirements-2i2c.txt file, run
- pip install -r requirements-2i2c.txt

If you just want to install few new modules or upgrade existing modules without updating environment or requirements file, 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 environment or requirements file when there is a need to update the environment as it helps reproducibility.

Subject Keywords

Content

Related Resources

This resource has been replaced by a newer version Dash, P. (2025). Scripts to Create Conda Environments in JupyterHub, HydroShare, http://www.hydroshare.org/resource/ece5940aa7cf4f50bd4b64e3f0051fce

How to Cite

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

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