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

Alias: pixi x

Arguments

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

string
Matchspecs of packages to install.If this is not provided, the package is guessed from the command name.Can be specified multiple times.
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.
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.
string
The platform to create the environment for. Defaults to the current platform.
boolean
If specified, a new environment is always created even if one already exists.
string
Before executing the command, list packages in the environment.Specify --list=some_regex to filter the shown packages.
boolean
Disable modification of the PS1 prompt to indicate the temporary environment.

Examples

Run a command with auto-guessed package

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

Run a command with specific package versions

Run a command with multiple packages

Run with additional dependencies

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

Use a specific channel

Force reinstall

List packages before execution

List only specific packages:

Cross-platform execution

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:

Use Cases

One-off Commands

Testing Different Versions

Quick Scripts

CI/CD

Package Guessing

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

Differences from pixi run

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