I am trying to re-enter my conda environment but I am having trouble doing so as when I type conda activate (evironment name) or source activate (environment name) both return the error 'Could not find conda environment.' This is very strange as when I type conda info --envs, I get this:
# conda environments:
#
base * /Users/(my name)/anaconda3
/anaconda3/envs/(environment name)
Names and Prefixes
For a Conda env to have a name it must be installed in one of the envs_dirs directories (see conda config --show envs_dirs). Creating an env outside of one of those forfeits its "name-ability". Instead, you must use the path (called its prefix) to activate it, e.g.,
conda activate /anaconda3/envs/my_env
Other commands will require you to use the --prefix|-p flag to specify the env. See the documentation on "Specifying the location for an environment".
Adding Other Env Locations
If you plan to frequently install in a different location than the default, then there is an option to add directories to the envs_dirs configuration variable. In your case, this would be
conda config --append envs_dirs /anaconda3/envs
Note that whatever you put in here will become the de facto default for future installs using the --name|-n flag. If you still want to keep the usually default (/Users/(my name)/anaconda3/envs), then you should follow the above with
conda config --prepend envs_dirs /Users/(my name)/anaconda3/envs
That is, this will let you pick up the "names" of the envs installed in /anaconda3/envs, but calling conda create -n foo will still create it in /Users/(my name)/anaconda3/envs/foo.
Documentation: conda config --describe envs_dirs.
来源:https://stackoverflow.com/questions/58369030/could-not-find-conda-environment