Skip to main content

Command referenceconda run

conda run command (Linux & Windows / Conda)

Linux & WindowsCondapackageintermediate

What it does

Run a command inside a Conda environment without permanently activating it in the parent shell. When people look up conda run command, they usually want safe flags, copyable examples, and how this Conda subcommand fits Anaconda or Miniconda workflows on Linux, Windows, and macOS. Syntax, options, and practical examples are below.

Run a command inside a Conda environment without permanently activating it in the parent shell.

Syntax

conda run [-n ENV | -p PATH] [--no-capture-output] COMMAND ...

Common options

Flag / optionMeaning
-n, --nameEnvironment name to use.
-p, --prefixEnvironment prefix to use.
--no-capture-outputStream stdout/stderr live (useful for CLIs).
-v, --verboseShow more diagnostic output.

Practical examples

Run a script

conda run -n ml python train.py

Executes train.py with ml's Python without activating ml.

Live output

conda run --no-capture-output -n web flask run

Keeps server logs visible in real time.

One-off tool

conda run -n tools rg "TODO" src

Handy in scripts and CI where shell init is awkward.

Prefix env

conda run -p ./envs/demo pytest

Runs pytest using a path-based environment.

Common mistakes

  • Omitting `--no-capture-output` for long-running servers and wondering why logs appear late.
  • Expecting env vars exported in the parent shell to always replace the env's own settings.

FAQ

What does conda run do in Conda?

Run a command inside a Conda environment without permanently activating it in the parent shell.

Does conda run work on Windows and Linux?

Yes. Conda runs on Linux, Windows, and macOS; shell activation differs slightly after `conda init`, but the CLI flags are the same.

What is a practical conda run example?

Try `conda run -n ml python train.py` — Executes train.py with ml's Python without activating ml.

Is mamba the same as conda run?

Mamba is a faster drop-in solver for many Conda workflows. Prefer `mamba` only when it is installed; otherwise use the Conda commands on this page.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.