Solving "CommandNotFoundError"

Are you experiencing the annoying CommandNotFoundError when trying to use conda activate? Don't worry! We've got you covered. In this guide, we will walk you through a step-by-step process to properly configure your shell for conda activate. By the end of this guide, you will have fixed this issue and will be able to use conda activate without any hassle.

Table of Contents

  1. Understanding CommandNotFoundError
  2. Step-by-Step Guide to Configure Your Shell
  3. FAQs

Understanding CommandNotFoundError

The CommandNotFoundError is an error message that occurs when your shell is not properly configured to use conda activate. This error is common among users who have recently installed Anaconda or Miniconda and are trying to activate a conda environment for the first time.

The error message usually looks like this:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.

To fix this issue, you need to configure your shell to recognize the conda command and the activate sub-command.

Step-by-Step Guide to Configure Your Shell

Follow the steps below to configure your shell for conda activate:

Step 1: Determine Your Shell

First, you need to determine which shell you are using. To do this, open a terminal and run the following command:

echo $SHELL

The output will show the path to your shell. Some common shells are:

  • /bin/bash
  • /bin/zsh
  • /bin/fish

Step 2: Edit Your Shell's Configuration File

Depending on your shell, open the appropriate configuration file using a text editor. For example:

  • For bash, edit ~/.bashrc (Linux) or ~/.bash_profile (macOS)
  • For zsh, edit ~/.zshrc
  • For fish, edit ~/.config/fish/

Add the following lines to your shell's configuration file, replacing <path-to-anaconda> with the actual path to your Anaconda or Miniconda installation:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('<path-to-anaconda>/bin/conda' 'shell.<shell-name>' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
    if [ -f "<path-to-anaconda>/etc/profile.d/" ]; then
        . "<path-to-anaconda>/etc/profile.d/"
        export PATH="<path-to-anaconda>/bin:$PATH"
unset __conda_setup
# <<< conda initialize <<<

Replace <shell-name> with the name of your shell (bash, zsh, or fish).

Step 3: Reload Your Shell Configuration

Now, you need to reload your shell's configuration to apply the changes. To do this, run one of the following commands in your terminal:

  • For bash or zsh: source ~/.bashrc or source ~/.zshrc
  • For fish: source ~/.config/fish/

Step 4: Test conda activate

To make sure that the CommandNotFoundError has been resolved, try activating a conda environment:

conda activate <your-environment-name>

If everything is configured correctly, you should be able to activate the environment without any errors.


Q1: What is 'conda activate'?

conda activate is a command used to activate a conda environment. Conda environments are isolated spaces where packages and dependencies can be installed without interfering with each other. Activating an environment sets up your shell to use the specific packages and dependencies installed in that environment.

Q2: Can I use 'source activate' instead of 'conda activate'?

source activate is an older command that is no longer recommended. It is advised to use conda activate because it handles environment activation more consistently across different platforms and shells.

Q3: Why do I need to configure my shell for 'conda activate'?

Configuring your shell for conda activate allows your shell to recognize the conda command and its sub-commands, such as activate. This is necessary for using conda environments and managing packages within them.

Q4: How do I find the path to my Anaconda or Miniconda installation?

To find the path to your Anaconda or Miniconda installation, you can run the following command in your terminal:

which conda

This will output the path to the conda executable, which is located in the bin directory of your Anaconda or Miniconda installation.

Q5: Can I configure my shell for 'conda activate' on Windows?

Yes, you can configure your shell for conda activate on Windows. The process is similar to that described for Linux and macOS but involves editing different configuration files depending on your shell. For example, you might need to edit ~/.bashrc for Git Bash, ~/.zshrc for Zsh on Windows Subsystem for Linux (WSL), or ~/.config/powershell/Microsoft.PowerShell_profile.ps1 for PowerShell.

Related links:

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.