How to switch environments in conda
To switch (or activate) different environments using Conda, you can use the conda activate
command followed by the name of the environment you want to activate.
Here’s how you can do it:
-
For Windows (using Command Prompt or Anaconda Prompt):
conda activate myenv
-
For macOS and Linux:
source conda activate myenv
Note: In newer versions of Conda on macOS and Linux, you can also use
conda activate myenv
directly without thesource
prefix.
Where myenv
is the name of the environment you want to activate.
To deactivate the current environment and return to the base environment, you can use:
conda deactivate
If you’re unsure about the names of your environments, you can list all of your Conda environments with:
conda env list
or
conda info --envs
This will show a list of all your environments, and the currently active environment will be marked with an asterisk (*
).
conda is an alternative package management tool bundled with the Anaconda python distribution. In some ways conda is a replacement for pip.
Here is how you upgrade all conda installed python packages with one command.
conda update --all
# update all packages unprompted
conda update --all -y
# list packages that can be updated
conda search --outdated