VMHeaven

Troubleshooting

conda: command not found — initialise conda in bash and zsh

conda is usually installed but never initialised for your shell. Fix 'conda: command not found' in bash, zsh, cron, Docker and on Windows.

Updated 19 Sept 2026~6 min read

bash: conda: command not found (or zsh: command not found: conda) almost never means conda is missing. It usually means conda is installed but your shell was never set up to use it. The Miniconda, Anaconda and Miniforge installers ask whether to initialise your shell. If you answered no, or installed unattended with -b, the setup block was never written, so conda sits in your home directory where the shell does not look.

The fix takes a minute: find the install, run conda init once for your shell, and open a new terminal.

1. Find where conda is installed

bash · zsh
ls -d ~/miniconda3 ~/anaconda3 ~/miniforge3 \
      /opt/conda /opt/miniconda3 /opt/anaconda3 2>/dev/null

Nothing listed? Search for the binary itself. If this finds nothing either, conda is genuinely not installed — skip to installing it.

search
find / -path '*/bin/conda' -type f 2>/dev/null | head

2. Initialise your shell

Run conda init through its full path, as the user who will use conda, not with sudo. Pick the shell you actually use: macOS has defaulted to zsh since Catalina, and most Linux servers use bash.

bash · zsh
# bash
~/miniconda3/bin/conda init bash
source ~/.bashrc

# zsh
~/miniconda3/bin/conda init zsh
source ~/.zshrc

Replace ~/miniconda3 with the directory you found in step 1. conda init --all sets up every shell it knows. Opening a new terminal works as well as the source line.

verify
conda --version
conda info --envs

What conda init actually changes

It adds a block between # >>> conda initialize >>> markers to ~/.bashrc, ~/.zshrc or ~/.bash_profile on macOS. That block runs conda shell.bash hook (or the zsh equivalent), which does two things:

  • puts the conda bin directory on your PATH, and
  • defines conda as a shell function, which is what makes conda activate able to change the environment of the current shell.

That second point explains the most common follow-up error, covered next.

“Your shell has not been properly configured to use ‘conda activate’”

You get CommandNotFoundError when the conda binary is on your PATH — for example because you added it with export PATH=… — but the shell function was never loaded. Adding the directory to PATH is not enough for activate. Run conda init as above and open a new shell, or load the hook for the current session only:

current shell only
eval "$(~/miniconda3/bin/conda shell.bash hook)"
conda activate myenv

Scripts, cron, systemd and SSH commands

~/.bashrc is read by interactive shells only. Cron jobs, systemd units, CI steps and ssh host ‘command’ skip it, so conda is “not found” there even after conda init. Do not try to activate an environment in those places. Call it directly:

non-interactive
# simplest: the environment's own interpreter
/home/deploy/miniconda3/envs/myenv/bin/python /opt/app/job.py

# or let conda set up the environment for one command
/home/deploy/miniconda3/bin/conda run -n myenv python /opt/app/job.py

# inside a bash script that really needs 'conda activate'
source ~/miniconda3/etc/profile.d/conda.sh
conda activate myenv

The first form is the most robust for crontab lines and ExecStart= in systemd units, because it depends on nothing but an absolute path.

“sudo: conda: command not found”

A per-user install lives in your home directory, and sudo runs with root’s PATH. That is expected. Conda environments should not need root. If one step genuinely does, use the full path to the binary rather than installing a second conda for root.

Installing conda if it really is missing

On a server, a minimal installer is the right choice. Miniforge uses the community conda-forge channel by default. Miniconda uses Anaconda’s channel, whose terms of service matter for commercial use in larger organisations.

Linux · Miniforge
wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash "Miniforge3-$(uname)-$(uname -m).sh"
Linux · Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

Answer yes when the installer offers to initialise your shell. For an unattended install, -b skips the questions, so add the init step yourself:

unattended
bash Miniforge3-$(uname)-$(uname -m).sh -b -p "$HOME/miniforge3"
"$HOME/miniforge3/bin/conda" init bash

No wget on the box? See wget: command not found, or use curl -LO with the same URL.

In a Docker image

Dockerfile RUN steps are non-interactive shells too. Put conda on the PATH with ENV and use conda run for commands inside an environment. Better still, start from condaforge/miniforge3 or continuumio/miniconda3, which already do this.

Dockerfile
FROM condaforge/miniforge3
COPY environment.yml .
RUN conda env create -f environment.yml
# run later RUN steps inside the environment
SHELL ["conda", "run", "-n", "myenv", "/bin/bash", "-c"]
RUN python -c "import numpy; print(numpy.__version__)"

On Windows

The Windows version of this error reads ‘conda’ is not recognized as an internal or external command. The installer deliberately does not add conda to the system PATH. Open Anaconda Prompt or Miniforge Prompt from the Start menu, then run this once to use conda from ordinary terminals:

Anaconda / Miniforge Prompt
conda init powershell
conda init cmd.exe

If PowerShell then complains that running scripts is disabled, allow signed local profile scripts for your account with Set-ExecutionPolicy -Scope CurrentUser RemoteSigned and open a new window.

Data science jobs are usually CPU-bound. If you are setting up a box for them, the Hi-CPU KVM line runs on high-clock cores that shorten single-threaded work like pandas pipelines.

Frequently asked

How do I fix conda: command not found after installing Miniconda?

Run the init step through the full path, e.g. '~/miniconda3/bin/conda init bash' (or zsh), then open a new terminal. The installer only does this if you answered yes to its initialisation prompt.

Why does conda work in my terminal but not in cron or a script?

conda init writes to ~/.bashrc, which only interactive shells read. In cron, systemd or scripts call the environment's interpreter directly (…/envs/myenv/bin/python) or use 'conda run -n myenv'.

Should I add conda to PATH manually instead?

It makes the conda binary visible but not 'conda activate', which needs the shell function that conda init sets up. Use conda init for interactive shells and absolute paths everywhere else.

More in Troubleshooting

See all