user3889486
user3889486

Reputation: 656

conda command not available in conda environment per default

Why I cannot update conda from a conda environment, but I can use it?

An example

I can update conda from root

[ravas@localhost ~]$ source activate
(base) [ravas@localhost ~]$ conda update conda
Solving environment: done

# All requested packages already installed.

I cannot update it from p36:

(base) [ravas@localhost ~]$ source activate p36
(p36) [ravas@localhost ~]$ conda update conda

PackageNotInstalledError: Package is not installed in prefix.
  prefix: /home/ravas/miniconda3/envs/p36
  package name: conda

This seems to occurs as conda is not installed in p36

(base) [ravas@localhost ~]$ conda list | grep conda
# packages in environment at /home/ravas/miniconda3:
anaconda-client           1.7.1                    py37_0  
anaconda-navigator        1.9.2                    py37_0  
conda                     4.5.11                   py37_0  
conda-env                 2.6.0                         1  

(p36) [ravas@localhost ~]$ conda list | grep conda
# packages in environment at /home/ravas/miniconda3/envs/p36:
anaconda                  5.3.0                    py36_0  
anaconda-client           1.7.2                    py36_0  
anaconda-project          0.8.2                    py36_0  
pdfminer.six              20170720                 py36_0    conda-forg

However, from p36 I can use conda

(p36) [ravas@localhost ~]$ conda update anaconda
Solving environment: done

# All requested packages already installed.

Why is that?

Upvotes: 0

Views: 8942

Answers (2)

user69453
user69453

Reputation: 1405

conda is not installed in the new environment. But you can get a conda in that derived environment like this:

  • activate the base environment
  • activate your other environment
  • run a conda install conda

Now you have a conda in that other environment, and work with that environment as usually.

Upvotes: 1

darthbith
darthbith

Reputation: 19617

This is a consequence of how the shell (Bash, zsh, csh, fish, etc.) finds programs to execute. (The shell is the program that is running to process the commands you type in the terminal). The shell looks for executables in folders that are specified in the PATH environment variable. It searches these folders in the order that they're specified in that variable. If you look at the contents of the PATH with your environment activated, it should look something like

$ echo $PATH
/home/ravas/miniconda3/envs/p36/bin:/home/ravas/miniconda3/bin:...

When the shell tries to find the conda executable, it looks first in the environment directory; when it doesn't find it there, it looks in the base directory, where it does find it!

Upvotes: 1

Related Questions