Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find conda environment

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)
like image 846
Bob Samuels Avatar asked Oct 14 '19 01:10

Bob Samuels


People also ask

Could not find Conda environment TensorFlow?

Could Not Find Conda Environment Tensorflow? Creating a Python environment using python version 3.7 as well as specific python version tarballs will generate Conda environments. You will need to install tensorflow 2 on your computer in the CUDA environment. How Do You Add Tensorflow To Conda Environment?

Does the environment created by Conda have a name?

the environment is created but has no name. This is confirmed as I get: in the prompt. In addition when using conda env list, the created environment has no name, but does have a path. I still have to update the .condrc to append to the envs_dirs key to add the environment, despite using the latest version of conda.

How to list all discoverable environments in Anaconda?

You can list all discoverable environments with `conda info --envs`. I'm not even sure what debugging steps to take in this case. I've verified that conda comes from the right anaconda path, etc.

How to activate Conda from the command line?

Conda enables activation through type *yourenvironmentname> in the command line.It should be noted that this version of conda activates Discovery rather than Discovery.This command will help you to install a particular package.


1 Answers

Names and Prefixes

For a Conda environment to have a name it must be installed in one of the envs_dirs directories (see conda config --show envs_dirs). Creating an environment outside of one of those forfeits its "name-ability". Instead, one must use the path (called its prefix) to activate it, e.g.,

conda activate /anaconda3/envs/my_env

Other commands will require one to use the --prefix|-p flag to specify the environment. See the documentation on "Specifying the location for an environment".

Adding Other Env Locations

If one plans 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 this specific case, this would be

conda config --append envs_dirs /anaconda3/envs

Note that whatever directory one specifies in this command will become the de facto default for future installs using the --name|-n flag. If one still wants to keep the standard default (/Users/<user>/anaconda3/envs), then they should follow the above with

conda config --prepend envs_dirs /Users/<user>/anaconda3/envs

That is, this will let one pick up the "names" of the environments installed in /anaconda3/envs, but calling conda create -n foo would still create it in /Users/(my name)/anaconda3/envs/foo.

For documentation, see: conda config --describe envs_dirs

like image 108
merv Avatar answered Sep 27 '22 22:09

merv