Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Current »

Goal: Introduce how conda environments can be reproduced and shared.

Based on Managing Environments.


In the following examples, we assume you already have a miniconda3 module already loaded.


Clone an Environment

[]$ conda create --help
...
options:
...
  --clone ENV           Create a new environment as a copy of an existing local environment.
...

Example

[]$ conda create -p py_env2 --clone py_env
Retrieving notices: ...working... done
Source:      /home/<username>/.conda/envs/py_env
Destination: /cluster/medbow/project/<project-name>/<username>/software/py_env2
Packages: 39
Files: 1
...
#
# To activate this environment, use
#     $ conda activate /cluster/medbow/project/<project-name>/<username>/software/py_env2
 Full Details:
[]$ pwd
/project/<project-name>/<username>/software
[]$ ls
slim_env_4.2.2

[]$ conda create -p py_env2 --clone py_env
Retrieving notices: ...working... done
Source:      /home/<username>/.conda/envs/py_env
Destination: /cluster/medbow/project/<project-name>/<username>/software/py_env2
Packages: 39
Files: 1

Downloading and Extracting Packages:


Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate /cluster/medbow/project/<project-name>/<username>/software/py_env2
#
# To deactivate an active environment, use
#
#     $ conda deactivate


[]$ ls
py_env2  slim_env_4.2.2

Using Cloned Environment

Notice how you need to activate/use this cloned environment:

[]$ cat ~/.conda/environments.txt
/home/<username>/.conda/envs/py_env
/project/<project-name>/<username>/conda/envs/r_env
/cluster/medbow/project/<project-name>/<username>/software/slim_env_4.2.2
/cluster/medbow/project/<project-name>/<username>/software/py_env2


[]$ conda info --env
# conda environments:
#
base                     /apps/u/opt/linux/miniconda3/24.3.0
                         /cluster/medbow/project/<project-name>/<username>/software/py_env2
                         /cluster/medbow/project/<project-name>/<username>/software/slim_env_4.2.2
py_env                   /home/<username>/.conda/envs/py_env
r_env                    /project/<project-name>/<username>/conda/envs/r_env

Need to define the full path to activate.

[]$ conda activate /cluster/medbow/project/<project-name>/<username>/software/py_env2
(/cluster/medbow/project/<project-name>/<username>/software/py_env2) []$ 

Export an Environment

[]$ conda activate r_env
(r_env) []$ conda env export > r_env.yml
(r_env) []$ conda deactivate

[]$ cat r_env.yml
name: r_env
channels:
  - conda-forge
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
...
  - zstd=1.5.5=hc292b87_2
prefix: /project/<project-name>/<username>/conda/envs/r_env

Conda env command

[]$ conda env --help
usage: conda env [-h] command ...

positional arguments:
  command
    config    Configure a conda environment.
    create    Create an environment based on an environment definition file.
    export    Export a given environment
    list      List the Conda environments.
    remove    Remove an environment.
    update    Update the current environment based on environment file.

options:
  -h, --help  Show this help message and exit.

Import an Environment

[]$ cd /project/<project-name>/<username>/software/
[]$ conda env create -p r_env2 --file r_env.yml
...
#
# To activate this environment, use
#
#     $ conda activate /cluster/medbow/project/<project-name>/<username>/software/r_env2
...

 

  • No labels