Skip to content
Happy Programming Guide
Start learning
Python

Conda Error: Argument COMMAND Invalid Choice ‘activate’

This error means your shell has not been set up for conda. Here is what conda init does, why it is needed, and the fix for each shell including PowerShell.

Modern Desk Setup with Tofu 60 and Logitech MX Master 3 and a wooden wrist rest

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#

Terminal
conda activate myenv
Output
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#

Terminal
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:

Terminal
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:

Terminal
conda activate myenv
conda deactivate

Windows PowerShell#

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:

POWERSHELL
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#

Terminal
conda init bash

Git Bash sometimes needs a nudge, because it reads .bash_profile rather than .bashrc:

Terminal
echo ". ~/.bashrc" >> ~/.bash_profile

macOS and Linux#

Terminal
conda init zsh      # macOS default since Catalina
conda init bash     # most Linux distributions

Check which shell you are actually in before choosing:

Terminal
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:

Terminal
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:

Terminal
#!/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:

Terminal
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#

Terminal
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:

Terminal
~/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#

Command line basics, including what PATH actually isRead next

Keep reading

Python

Web Scraping and Automation

How to scrape a web page with Python responsibly: requests and BeautifulSoup, reading robots.txt, rate limiting, and when to use an API…

5 min read

Keep going — pick your next guide

The fastest way to improve is to read one guide, then build the thing it describes. Start with the basics, or jump straight to a project.

Ask a question or share what worked

Your email address will not be published. Required fields are marked *