Command referenceconda run
conda run command (Linux & Windows / Conda)
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 / option | Meaning |
|---|---|
| -n, --name | Environment name to use. |
| -p, --prefix | Environment prefix to use. |
| --no-capture-output | Stream stdout/stderr live (useful for CLIs). |
| -v, --verbose | Show 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.
Related commands
- conda activateActivate a named or path-based Conda environment in the current shell session.
- conda initConfigure shell startup files so `conda activate` works in bash, zsh, PowerShell, cmd.exe, and others.
- conda createCreate a new isolated Conda environment with an optional Python version and starter packages.
- conda listList packages installed in the active or named Conda environment.
- conda installInstall packages into the active or named Conda environment from configured channels.
- conda env listList all Conda environments and mark the currently active one.
- aptSearch, install, update, and remove packages on Debian-based systems.
- conda env createCreate an environment from an environment.yml (or similar) specification file.
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.