Skip to main content
Runs a command in a temporary environment, installing the required packages on-the-fly. This is useful for running tools without permanently installing them. The temporary environments are cached and can be removed with pixi clean cache --exec.

Usage

pixi exec [OPTIONS] <COMMAND>...
Alias: pixi x

Arguments

COMMAND
string
required
The executable to run, followed by any arguments.If no package specs are provided with --spec, pixi will attempt to guess the package name from the command.

Options

--spec
string
Matchspecs of packages to install.If this is not provided, the package is guessed from the command name.Can be specified multiple times.
--with
string
Matchspecs of packages to install, while also guessing a package from the command.This option allows you to specify additional dependencies alongside the auto-guessed package.Cannot be used together with --spec.
--channel
string
The channels to consider as a name or a URL. Multiple channels can be specified by using this field multiple times.When specifying a channel, it is common that the selected channel also depends on the conda-forge channel.By default, if no channel is provided, conda-forge is used.
--platform
string
The platform to create the environment for. Defaults to the current platform.
--force-reinstall
boolean
If specified, a new environment is always created even if one already exists.
--list
string
Before executing the command, list packages in the environment.Specify --list=some_regex to filter the shown packages.
--no-modify-ps1
boolean
Disable modification of the PS1 prompt to indicate the temporary environment.

Examples

Run a command with auto-guessed package

pixi exec python --version
This will install Python in a temporary environment and run python --version.

Run a command with specific package versions

pixi exec --spec python==3.12 python script.py

Run a command with multiple packages

pixi exec --spec jupyter --spec polars jupyter lab

Run with additional dependencies

pixi exec --with polars jupyter lab
This installs both jupyter (guessed from the command) and polars (specified with --with).

Use a specific channel

pixi exec --channel conda-forge --channel bioconda samtools --version

Force reinstall

pixi exec --force-reinstall python script.py

List packages before execution

pixi exec --list python --version
List only specific packages:
pixi exec --list="numpy.*" python script.py

Cross-platform execution

# On macOS ARM, run a tool for x86_64
pixi exec --platform osx-64 some-tool

How It Works

  1. Package Resolution: If --spec is not provided, pixi guesses the package name from the command
  2. Environment Creation: Pixi creates (or reuses) a cached environment with the required packages
  3. Execution: The command runs in the activated environment
  4. Caching: The environment is cached for future use
Temporary environments are stored in the pixi cache directory and are reused across invocations with the same dependencies.

Environment Naming

Temporary environments are named based on:
  • The command name
  • The package specifications
  • The channels used
  • The target platform
The same environment is reused for identical combinations.

Cleaning Up

Remove all temporary exec environments:
pixi clean cache --exec

Use Cases

One-off Commands

# Run a tool without installing it globally
pixi exec cowpy "Hello World"

Testing Different Versions

pixi exec --spec python==3.8 python --version
pixi exec --spec python==3.12 python --version

Quick Scripts

pixi exec --spec "python==3.12" --with "requests" python -c "import requests; print(requests.get('https://api.github.com').json())"

CI/CD

# In GitHub Actions
- name: Run tool
  run: pixi exec cowpy "Build successful!"

Package Guessing

When you don’t specify --spec, pixi attempts to guess the package name:
pixi exec python --version  # Guesses package name: python
pixi exec jupyter lab       # Guesses package name: jupyter
Illegal characters in the command are replaced with dashes.
Use pixi x as a shorthand for pixi exec.

Differences from pixi run

Featurepixi execpixi run
ScopeTemporary environmentProject environment
Package sourceSpecified via CLIFrom pixi.toml
CachingAutomaticN/A
Use caseOne-off commandsProject tasks

Environment Variables

The temporary environment sets:
  • PIXI_ENVIRONMENT_NAME: temp:<package-names>
  • PS1 or _PIXI_PROMPT: Modified prompt (unless --no-modify-ps1)
  • All standard conda environment variables