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
Key Concepts
Features
A feature is a collection of:- Dependencies
- Tasks
- Channels
- Platform configurations
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: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
With Solve Groups
Environment Without Default Feature
Sometimes you want an environment without the default dependencies:Feature-Specific Tasks
Tasks can be associated with features: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 completepixi.toml with multiple environments:
Best Practices
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
- Learn about importing environments from other formats
- Explore Python development workflows
- Understand pyproject.toml integration