conda: error: argument COMMAND: invalid choice: 'activate' means your shell is running the conda program directly, without the shell function that activate requires. Activating an environment has to change variables in your current shell, and a program cannot do that from the outside. The fix is conda init, followed by opening a new terminal.
What the error looks like#
conda activate myenv
usage: conda [-h] [-V] command ...
conda: error: argument COMMAND: invalid choice: 'activate'
(choose from 'clean', 'config', 'create', 'info', 'install', 'list',
'remove', 'search', 'update', ...)
Look at that list: activate genuinely is not among conda’s subcommands. That is the clue.
Why activate is different#
Activating an environment means changing PATH and a few other variables in the shell you are sitting in. A child process cannot do that to its parent — when the program exits, its environment goes with it.
So conda installs a shell function called conda that wraps the real program. When you type conda activate, the function handles it inside your shell; anything else is passed through to the executable. If that function was never installed, your shell finds the raw executable instead, which has no idea what activate means.
The fix#
conda init
Then close the terminal and open a new one. This is the step people skip. conda init edits your shell’s startup file, and startup files are only read when a shell starts.
You can name a shell explicitly:
conda init bash
conda init zsh
conda init powershell
conda init cmd.exe
conda init fish
conda init --all
After restarting, your prompt should begin with (base), and this should work:
conda activate myenv
conda deactivate
Windows PowerShell#
conda init powershell
If the new window then reports that running scripts is disabled, PowerShell’s execution policy is blocking the profile conda just wrote:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
CurrentUser scope avoids changing the policy for the whole machine. Restart PowerShell afterwards.
If PowerShell is awkward, the Anaconda Prompt shortcut in the Start menu is already configured and works out of the box.
Git Bash on Windows#
conda init bash
Git Bash sometimes needs a nudge, because it reads .bash_profile rather than .bashrc:
echo ". ~/.bashrc" >> ~/.bash_profile
macOS and Linux#
conda init zsh # macOS default since Catalina
conda init bash # most Linux distributions
Check which shell you are actually in before choosing:
echo $SHELL
conda init appends a block to ~/.zshrc or ~/.bashrc marked with >>> conda initialize >>>. If activation stops working later, check whether something else in that file overwrites PATH after the conda block.
The alternative: source the script directly#
On a shared machine, or in a script where you would rather not modify startup files:
source /path/to/anaconda3/etc/profile.d/conda.sh
conda activate myenv
This is also the correct approach inside shell scripts and CI jobs, where startup files are often not read at all:
#!/usr/bin/env bash
set -euo pipefail
source "$(conda info --base)/etc/profile.d/conda.sh"
conda activate myproject
python analyse.py
conda info --base finds the installation path for you, so the script works on any machine.
The old syntax#
Guides written before conda 4.4 used:
source activate myenv # macOS and Linux
activate myenv # Windows
These still work in some installations but are deprecated. Use conda activate in anything new.
Checking it worked#
conda env list # the active one is marked with *
conda info --envs
which python # should point inside the environment
python -c "import sys; print(sys.prefix)"
If conda is not found at all#
A different error — conda: command not found — means the installation is not on your PATH. Locate it and run conda init using the full path:
~/anaconda3/bin/conda init bash
# or
~/miniconda3/bin/conda init zsh
Questions people ask#
Do I need conda if I already use venv?
No. venv plus pip handles pure Python projects perfectly well. Conda earns its place when you need non-Python dependencies — compilers, CUDA, some geospatial and scientific libraries — that pip cannot install.
Is it safe to run conda init more than once?
Yes. It detects its own block and will not duplicate it. conda init --reverse removes it again.
How do I stop conda activating base in every terminal?
Run conda config --set auto_activate_base false. Conda stays available; it just does not activate anything until you ask.
Can I use conda and pip together?
Yes, with care. Install what you can with conda first, then use pip for the rest inside the same environment. Alternating between the two for the same package is what causes broken environments.
Where to go next#
- Python virtual environments — the venv alternative, explained.
- Command line basics for beginners — PATH and shell startup files.
- Fixing ModuleNotFoundError for pandas — usually the wrong environment.