2

I have already created my own environment using conda in linux. When I check conda info --envs, it gives a list of environment like

# conda environments:
#
base                  *  /home1/sriparna/anaconda3
copy_Env_deepgo          /home1/sriparna/anaconda3/envs/copy_Env_deepgo
deepgo_2                 /home1/sriparna/anaconda3/envs/deepgo_2
deepgo_3                 /home1/sriparna/anaconda3/envs/deepgo_3
enzy                     /home1/sriparna/anaconda3/envs/enzy
parth                    /home1/sriparna/anaconda3/envs/parth
protein_struc            /home1/sriparna/anaconda3/envs/protein_struc
py2                      /home1/sriparna/anaconda3/envs/py2

But I cant activate a particular environment. e.g. when I tried conda activate parth it shows

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

Please help me regarding this.

Pratik Dutta
  • 125
  • 1
  • 2
  • 11
  • @Simba's answer is the best practice, however, it already covered in this possible duplicate: [How to run Conda?](https://stackoverflow.com/questions/18675907/how-to-run-conda). – merv Sep 24 '19 at 16:05

3 Answers3

9

This worked for me:

source {path_to_anaconda}/anaconda3/etc/profile.d/conda.sh
conda activate parth
saccodd
  • 972
  • 9
  • 23
  • awesome friend, I was facing the same issue and your point worked for me – Pelab Jan 12 '21 at 20:36
  • This works in `git bash` on Windows 10 for a current shell session with a path `/c/Program\ Files/Anaconda3/etc/profile.d/conda.sh`. To find conda path `conda info | grep -i 'base environment'` – Vladislav Povorozniuc Aug 10 '22 at 13:07
3

Conda is not initialized in your shell. Run the following commands in an interactive shell,

conda init

Conda will detect the type of your shell, and write init scripts into the shell's configuration file. (Running it once is enough.)

Detail

Conda updated its environment activation after 4.6.

Quote from conda 4.6 release log

Conda 4.4 allowed “conda activate envname”. The problem was that setting up your shell to use this new feature was not always straightforward. Conda 4.6 adds extensive initialization support so that more shells than ever before can use the new “conda activate” command. For more information, read the output from “conda init –help”

In previous conda, the binaries installed by the default env "base" are exposed into the shell.

After conda init is introduced in conda 4.6, conda only expose command conda into the PATH. And environment switch is unified by conda activate env-name and conda deactivate on all platforms. But to make these commands work, you have to do an additional initialization with conda init.

Read the conda 4.6 release log for more detail.

Simba
  • 23,537
  • 7
  • 64
  • 76
0

I had installed anaconda in Ubuntu VM environment but base was not loading, tried adding the PATH to .bashrc, didn't solve as Conda:not found was error.

Then I solved through:

Press F1>>Terminal: Select Default Profile

You might have available options :

  • bash
  • fish
  • tcsh
  • xonsh
  • zsh
  • powershell

Choose YOUR_SHELL_NAME

Run:

eval "$(/home/mishra/anaconda3/bin/conda shell.YOUR_SHELL_NAME hook)" 

#example

 eval "$(/home/mishra/anaconda3/bin/conda shell.bash hook)"

Immediately (base) will show