conda Verified current stable Not installed? Package Management

Conda / Export Environment By Path

Export Environment By Path

Exports the specified Conda environment by its path to retain its configuration.

$
Terminal
conda export -p <path/to/environment>

When To Use

When transitioning an environment from one system or user to another while retaining package integrity.

Pro Tip

Using `--no-builds` helps ensure that the exported package versions are platform-agnostic, reducing conflicts during recreations.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
# Exporting environment from /home/user/myenv to myenv.yml
Exporting environment to: myenv.yml
- package1=1.0.0
- package2=2.1.3
- package3=3.2.1

Anatomy of Output

Understanding the result

name: myenv Environment Name

The name of the environment being exported via its path.

dependencies: Installed Packages

Lists all dependencies irrespective of build specifications.

prefix: /path/to/myenv Environment Prefix

Specifies the full path of the environment.

Troubleshooting

Common pitfalls

EnvironmentPathNotFound: The environment at '/path/to/myenv' does not exist

Solution: Confirm that the specified path points to an active Conda environment.

OSError: [Errno 2] No such file or directory at path

Solution: Check the path for accuracy and the existence of the specified environment.

CondaError: Unable to export - Path not supported

Solution: Ensure the path syntax adheres to Conda specifications.

Command Breakdown

What each part is doing

conda
Base Command
The executable that performs this operation. Here it runs Conda before the shell applies any redirect operators.
-p
p| prefix
The value supplied for p| prefix.
<path/to/environment>
path to environment
The value supplied for path to environment.
-p
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Run the command: conda export --prefix /home/user/myenv > myenv.yml

  2. Step 2

    Verify the export with: cat myenv.yml | head -n 5

Alternative Approaches

Comparable commands in other tools

Alternative package management tools for the same job.