How to activate a miniconda environment in anaconda?

Question:

I installed miniconda on my macOS a few months ago.

Today I installed anaconda on the same computer.

Now I found that I can’t activate a miniconda environment by running conda activate my_miniconda_env.

Here’s my environments:

conda info --envs
# conda environments:
#
base                  *  /Users/my_name/opt/anaconda3
                         /Users/my_name/opt/miniconda3/envs/my_miniconda_env
                         /Users/my_name/opt/miniconda3/envs/my_miniconda_env2

When I run conda activate my_miniconda_env, I got the following error.

EnvironmentNameNotFound: Could not find conda environment: my_miniconda_env
You can list all discoverable environments with `conda info --envs`.

How can I activate those miniconda environments now?

Asked By: Brian

||

Answers:

It is perhaps a bit hidden or unexpected but you can use absolute path to activate every conda environment. Copying from conda activate --help:

ActivateHelp: usage: conda activate [-h] [–[no-]stack] [env_name_or_prefix]

Activate a conda environment.

Options:

positional arguments:
env_name_or_prefix The environment name or prefix to activate. If the
prefix is a relative path, it must start with ‘./’
(or ‘.’ on Windows).

More concretely, you can write:

conda activate /Users/my_name/opt/miniconda3/envs/my_miniconda_env

and it should work.

Note: This post is written for the sake of completion, since Brian said in the comments that it works for him.

Answered By: Yannis P.
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.