Skip to main content
Learn how to create and manage multiple environments within a single Pixi workspace to handle different use cases like development, testing, and production.

Why Multiple Environments?

When developing a project, you often need different sets of tools and dependencies:
  • Development: All tools including linters, formatters, and debuggers
  • Testing: Testing frameworks and coverage tools
  • Production: Only runtime dependencies for deployment
  • Documentation: Tools for generating and building docs
With Pixi’s multiple environments, you can define all these in one workspace and switch between them easily.

Key Concepts

Features

A feature is a collection of:
  • Dependencies
  • Tasks
  • Channels
  • Platform configurations
Features aren’t useful on their own - they must be part of an environment. Define a feature:

Environments

An environment is a collection of features that can be installed and activated. Define an environment:

Default Feature

The default feature contains top-level dependencies:
This is equivalent to:
The default feature is automatically included in all environments unless you use no-default-feature = true.

Getting Started

Testing Multiple Python Versions

A common use case is testing your code against multiple Python versions.

Development, Testing, and Production

Create separate environments for different stages:

Solve Groups

Solve groups ensure dependency versions are consistent across environments.

Without Solve Groups

Environments are solved independently and may have different versions.

With Solve Groups

Environments share the same dependency versions, preventing version mismatches between development and testing.
Use solve groups to ensure your tests run against the same dependency versions as your development environment.

Environment Without Default Feature

Sometimes you want an environment without the default dependencies:
Result:
Verify it doesn’t include default dependencies:
Output:

Feature-Specific Tasks

Tasks can be associated with features:
Run feature-specific tasks:
If a task exists in multiple environments, Pixi will prompt you to choose which one.

Platform-Specific Environments

Define platform-specific dependencies:

CI/CD Integration

GitHub Actions

Test multiple environments in parallel:

Docker Builds

Use the production environment in Docker:

Complete Example

Here’s a complete pixi.toml with multiple environments:

Best Practices

Use solve groups for related environments: Environments that should share versions (like dev and test) should be in the same solve group.
Keep production minimal: The production environment should only include runtime dependencies.
Organize features by purpose: Group related dependencies and tasks into features (dev, test, docs).
Use no-default-feature sparingly: Only use it for truly independent environments like documentation.

Troubleshooting

Tasks Not Found

If a task isn’t found, check which environments include its feature:

Version Conflicts

If environments have conflicting versions, ensure they’re in the same solve group:

Environment Not Created

Manually install an environment:

Next Steps