I have heard about pixi for a while now but have not had the chance to try it out until today.
When you head to their documentation, you will find the install instructions consist of a bash script piped directly into the terminal. This is not ideal, though admittedly conda does the same thing.
There is also an option to compile the binary from source. Since I have cargo installed, that seemed like the more principled approach.
So I first updated Rust:
rustup update
Then I installed pixi locally:
cargo install --locked --git https://github.com/prefix-dev/pixi.git pixi
This took a moment, but from here it was really a breeze to get going.
Pixi init
Unlike conda, pixi stores the environment together with the code in the same folder, which makes a lot of sense for project-based workflows. With conda, the binaries are often stored in a different location and it can be a bit of a hassle to manage them.
To create a new pixi environment, simply run:
pixi init .
Or:
pixi init my_project
The syntax is familiar — this is how git init works as well.
Once the environment is initialized, one can simply add dependencies. What I find neat is that pixi adds sane version ranges automatically, so you don’t have to specify them manually.
For example, if I add pandas:
pixi add pandas
Pixi will create the file pixi.toml with the following content:
[dependencies]
pandas = ">=3.0.1,<4"
This is a nice touch, as it ensures you are using compatible versions of your dependencies without any extra effort.
Pixi run
To run a script with the pixi environment, use:
pixi run python my_script.py
Pixi will take care of activating the environment and running the script with the correct dependencies.
To get a more conda-like feel, you can also activate the environment first and then run the script:
pixi shell
python my_script.py
This will activate the pixi environment for the current folder, after which you can run scripts as normal.
Conclusion
It is encouraging to see continued development in this space. Pixi was apparently initiated by a creator of Mamba, which gives me confidence that the team knows what they are doing when it comes to package and environment management.
Overall, getting started with pixi was very seamless, and I plan to adopt it for future projects.