Last updated: Apr 10, 2024
Reading time·3 min
⛔️ CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run $ conda init <SHELL_NAME> See 'conda init --help' for more information and options. IMPORTANT: You may need to close and restart your shell after running 'conda init'
To solve the error "CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'":
Open your terminal and run the following command. (Open Git Bash if you are on Windows)
source ~/anaconda3/etc/profile.d/conda.sh conda activate my_env
Make sure to replace my_env
with the name of your environment.
miniconda
is different than ~/anaconda3
, the command might fail.Use the following command to get your path to Anaconda.
conda info | grep -i 'base environment' conda info --base
~/anaconda3/
with the path to your Anaconda or miniconda installation.For example, the path for me is /home/borislav/anaconda3
, so I would issue the
following commands.
source /home/borislav/anaconda3/etc/profile.d/conda.sh conda activate my_env
Make sure to update your path based on the output of the conda info --base
command and specify the correct environment name when issuing the
conda activate
command.
If you are on Windows and the error persists, search for "Anaconda Prompt", open the application and issue the commands in Anaconda Prompt.
If the error persists, try to issue the following commands.
eval "$(conda shell.bash hook)" conda activate my_env
Make sure to specify the correct environment name.
You can use the conda env list
command to list your conda
environments.
conda env list
If you are in a script, you can set the CONDA_BASE
environment variable to the
output of the conda info --base
command.
CONDA_BASE=$(conda info --base)
Note that if you issue the conda init
command, you must restart your shell.
Make sure to run the following commands in Git Bash if you are on Windows.
If none of the suggestions helped, try to issue the following commands.
source ~/anaconda3/bin/activate source ~/miniconda3/bin/activate
ps -p $$
ps -p $$
command, initialize conda
for your
specific shell type.conda init <your-shell-type>
For example, if your shell type is bash
, you would run the following command.
conda init bash
My shell type is zsh
, so I ran the conda init zsh
command.
conda init zsh
Some of the supported shells for the conda init
command are:
conda init your_shell
command.Important: You need to close and restart your shell after running the
conda init
command.
conda actiavte
command.# 👇️ Activate base conda activate # 👇️ Or activate a specific environment conda activate my_env
Make sure to replace my_env
with the name of your conda
environment.
If the error persists, try to use the eval
command before running the
conda activate
command.
eval "$(conda shell.bash hook)" conda activate my_env
Make sure to replace my_env
with the name of your environment.