Troubleshoot
LinuxErrorsPythonServer Admin

bash: conda: command not found — Fix for bash & zsh

Fix 'bash: conda: command not found' after installing Miniconda or Anaconda. The shell init block is missing. One-command fix for bash and zsh.

May 9, 2026·3 min read

bash: conda: command not found — Fix for bash & zsh

bash: conda: command not found almost always means conda is installed but has not been initialised in your shell. The installer adds an init block to your shell config file — but only if you say yes at the prompt, or run conda init manually afterward.

Quick Fix

Run this as the user who installed conda:

# For bash
~/miniconda3/bin/conda init bash

# For zsh
~/miniconda3/bin/conda init zsh

# Then reload your shell
source ~/.bashrc
# or for zsh:
source ~/.zshrc

If conda was installed to a different path (e.g. ~/anaconda3), adjust accordingly:

ls ~/*/bin/conda 2>/dev/null || find / -name conda -type f 2>/dev/null | head -5

Why This Happens

The Miniconda/Anaconda installer asks:

Do you wish to update your shell profile to automatically initialize conda?

If you answered no (or ran the installer non-interactively with -b), the init block is never added. conda exists on disk but is not on your PATH and the conda shell function is not defined.

What conda init Actually Does

conda init appends a block like this to your ~/.bashrc (or ~/.zshrc):

# >>> conda initialize >>>
__conda_setup="$('/root/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/root/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/root/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/root/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

This adds conda to your PATH and defines the conda activate shell function.

Non-Interactive / CI Fix

In CI pipelines or scripts where you cannot source a shell config, use the full path directly:

# Activate an environment without conda init
source ~/miniconda3/etc/profile.d/conda.sh
conda activate myenv

Or add conda to PATH for the current session only:

export PATH="$HOME/miniconda3/bin:$PATH"
conda --version

Fix for Docker Containers

If conda is installed inside a Docker image but not initialised:

FROM debian:12-slim

# Install Miniconda
RUN apt-get update && apt-get install -y wget ca-certificates \
    && wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh \
    && bash /tmp/miniconda.sh -b -p /opt/conda \
    && rm /tmp/miniconda.sh

# Make conda available in all RUN steps
ENV PATH="/opt/conda/bin:$PATH"

RUN conda install -y numpy pandas

Using ENV PATH is the Docker-idiomatic way — no shell init required.

Verifying the Fix

conda --version
# Expected: conda 24.x.x

conda info
# Shows active env and conda locations

Common Follow-Up: conda activate Not Working

After conda init, if conda activate myenv still fails:

# Ensure base is not auto-activated if you don't want it
conda config --set auto_activate_base false

# List available environments
conda env list

# Activate manually
conda activate myenv
bash: conda: command not found — Fix for bash & zsh | VMHeaven Troubleshoot