Quickstart#

What is this?#

conda spawn is a replacement subcommand for the conda activate and conda deactivate workflow.

Instead of writing state to your current shell session, conda spawn -n ENV-NAME starts a new shell with your activated environment. To deactivate, exit the process with Ctrl+D, or run the command exit.

The typical workflow looks like this:

~ $ which python
python not found
~ $ which conda
/Users/user/Miniforge/condabin/conda
~ $ conda spawn -n base
(base) ~ $ which python
/Users/user/Miniforge/bin/python
(base) ~ $ python my_project.py
working ...
ok!
(base) ~ $ export VAR=1
(base) ~ $ echo $VAR
1
(base) ~ $ exit
~ $ echo $VAR

~ $

As you can see, variables set during the spawned shell session do not leak in the parent session once closed with exit. If you have used poetry shell or pixi shell, this is essentially the same but for conda.

Installation#

This is a conda plugin and goes in the base environment:

conda install -n base conda-forge::conda-spawn

After this, you might want to Clean up your shell initialization logic.

Usage#

To activate an environment named my-project:

conda spawn -n my-project

To deactivate, exit the process with Ctrl+D, or run the command exit.

Why?#

The main reasons include:

  • Cleaner shell interaction with no need for a conda shell function.

  • Avoid messing with existing shell processes.

  • Faster shell startup when conda is not needed.

  • Simpler installation and bookkeeping.

Do you want to learn more? Head over to Motivation and vision.