Environment Management with Pixi
Authors
Most software we are using comes with a list of dependencies which, in turn, have their own dependencies. This means that any given piece of software requires a specific environment of other packages to function properly. The larger the tree of dependencies, the more likely it is that two pieces of software have a version conflict because they require different versions of the same dependency. This can be prevented by using virtual environments. Virtual environments are self-contained boxes that are used only within a specific narrow scope. By creating a dedicated virtual environment for every project we can isolate the software and avoid conflicts. We can also improve the reproducibility of our research because the virtual environment can be shared together with the code and data.
In this notebook, you are going to learn how to use Pixi - a fast and modern tool for managing virtual environments.
Pixi allows us to set up new projects and install packages very quickly and with few steps.
What’s more, Pixi keeps track of our environment as we add new dependencies.
It creates a manifest called pixi.toml which contains a list of the dependencies we specified.
It also creates a file called pixi.lock which contains a comprehensive description of the virtual environment (i.e. the whole tree of dependencies).
These files allow us to exactly reproduce the computational environment.
Setup
The exercises in this notebook assume that you have installed Pixi and Visual Studio Code. If you haven’t, just click on the link and follow the instructions for your operating system on the website. To test if Pixi was installed correctly, open a terminal (in VSCode select View>Terminal from the menu bar or press Ctrl+`) and type pixi --version. If you are getting an error saying that the command was not found, try restarting VSCode.
pixi --versionpixi 0.58.0Section 1: Creating and Managing Environments
Background
To create a new Pixi project, open the terminal and move to the directory where you want to initialize the workspace. On Windows, you can also use the file explorer to go to the target directory and Right Click > Open in Terminal. Once you are in the directory, run pixi init, which will create the manifest pixi.toml file containing all dependencies you specified. Once you start installing dependencies, Pixi will create a .pixi/ directory where the installed software is stored as well as a pixi.lock file that contains an exact description of the current computational environment. To activate the environment, type pixi shell. Once the environment is activated, you’ll have access to all of the software installed with Pixi.
Exercises
In the following exercises, you are going to create a new Pixi workspace, install Python, and activate the virtual environment. Here are the commands you need to know.
| Code | Description |
|---|---|
cd my_dir/ |
Change the directory to my_dir/ |
cd .. |
Change the directory to the parent of the current directory |
mkdir new_dir/ |
Create the directory new_dir/ |
pixi init |
Initialize a new Pixi project with a pixi.toml |
pixi add python |
add python to your environment |
pixi add python==3.13 |
add Python version 3.13 to your environment |
pixi remove python |
Remove python from your environment |
pixi shell |
Activate the virtual environment |
Example: Create a new empty directory and move to that directory.
mkdir /tmp/new_project # create /tmp/new_project/
cd /tmp/new_project # move to /tmp/new_project//tmp/new_projectExercise: Create another new directory and move there. You can use your file explorer or the mkdir and cd commands as shown in the example above.
Solution
mkdir /tmp/my_project # create tmp/my_project/
cd /tmp/my_project # move to tmp/my_project/tmp/my_projectExercise: Run pixi init to initialize a new workspace in the current directory and open the pixi.toml file in VSCode.
Solution
pixi init✔ Created /tmp/my_project/pixi.toml
Exercise: Use pixi add to add Python to the environment.
Solution
pixi add python✔ Added python >=3.14.4,<3.15
Exercise: Use pixi shell to activate the environment and run python --version to print the version of the current python installation.
NOTE: Typing only python opens a Python shell. You can exit by typing exit().
Solution
pixi shell
python --versionPython 3.14.4Exercise: Use pixi remove to remove Python from the environment.
Solution
pixi remove python✔ Removed python
Exercise: Add python==3.12 to the environment
Solution
pixi add python==3.12✔ Added python==3.12
Exercise: Use pixi shell to activate the environment and run python --version to print the version of the current python installation.
Solution
pixi shell
python --versionPython 3.12.0Section 2: Installing Python Packages with Pixi
Background
There are two prominent places for publishing Python packages: Conda-Forge and the Python Package Index (PyPI). A nice feature of Pixi is that it can resolve dependencies across both repositories (i.e. it can make sure there is no version conflict between Conda and PyPI packages).
Per default, Pixi installs packages from Conda but we can tell it to install PyPI packages by adding the --pypi flag. Conda-forge tests distribution and integration more systematically and is able bundle packages with non-Python dependencies (e.g. C-libraries). However, many libraries (especially smaller ones) are only available on PyPI. Thus, it is recommended that you install packages from Conda-Forge and only use PyPI if a given package is not available there.
Exercises
In the following exercises you are going to install Python packages from Conda-Forge and PyPI. Here are the commands you need to know:
| Code | Description |
|---|---|
pixi add numpy |
Install numpy from Conda-Forge |
pixi add --pypi numpy |
Install package from PyPI |
pixi remove numpy |
Remove numpy from the environment |
pixi add matplotlib pandas |
Install multiple packages (matplotlib and pandas) |
pixi shell |
Activate the virtual environment |
pixi list |
View all currently installed packages |
Exercise: Install the packages numpy and matplotlib from Conda-Forge.
Solution
pixi add numpy matplotlib✔ Added numpy >=2.4.3,<3 ✔ Added matplotlib >=3.10.9,<4
Exercise: Use pixi list to verify the packages were installed.
Solution
pixi listPackage Version Build Size Kind Source _openmp_mutex 4.5 20_gnu 28.3 KiB conda https://conda.anaconda.org/conda-forge/ alsa-lib 1.2.15.3 hb03c661_0 571 KiB conda https://conda.anaconda.org/conda-forge/ brotli 1.2.0 hed03a55_1 19.6 KiB conda https://conda.anaconda.org/conda-forge/ brotli-bin 1.2.0 hb03c661_1 20.5 KiB conda https://conda.anaconda.org/conda-forge/ bzip2 1.0.8 hda65f42_9 254.1 KiB conda https://conda.anaconda.org/conda-forge/ ca-certificates 2026.4.22 hbd8a1cb_0 128 KiB conda https://conda.anaconda.org/conda-forge/ cairo 1.18.4 he90730b_1 966.3 KiB conda https://conda.anaconda.org/conda-forge/ contourpy 1.3.3 py312h0a2e395_4 312.9 KiB conda https://conda.anaconda.org/conda-forge/ cycler 0.12.1 pyhcf101f3_2 14.4 KiB conda https://conda.anaconda.org/conda-forge/ cyrus-sasl 2.1.28 hac629b4_1 205.2 KiB conda https://conda.anaconda.org/conda-forge/ dbus 1.16.2 h24cb091_1 437.2 KiB conda https://conda.anaconda.org/conda-forge/ double-conversion 3.4.0 hecca717_0 70.1 KiB conda https://conda.anaconda.org/conda-forge/ font-ttf-dejavu-sans-mono 2.37 hab24e00_0 388.1 KiB conda https://conda.anaconda.org/conda-forge/ font-ttf-inconsolata 3.000 h77eed37_0 94.3 KiB conda https://conda.anaconda.org/conda-forge/ font-ttf-source-code-pro 2.038 h77eed37_0 684.4 KiB conda https://conda.anaconda.org/conda-forge/ font-ttf-ubuntu 0.83 h77eed37_3 1.5 MiB conda https://conda.anaconda.org/conda-forge/ fontconfig 2.17.1 h27c8c51_0 264.4 KiB conda https://conda.anaconda.org/conda-forge/ fonts-conda-ecosystem 1 0 3.6 KiB conda https://conda.anaconda.org/conda-forge/ fonts-conda-forge 1 hc364b38_1 4 KiB conda https://conda.anaconda.org/conda-forge/ fonttools 4.62.1 py312h8a5da7c_0 2.8 MiB conda https://conda.anaconda.org/conda-forge/ freetype 2.14.3 ha770c72_0 169.8 KiB conda https://conda.anaconda.org/conda-forge/ graphite2 1.3.14 hecca717_2 97.3 KiB conda https://conda.anaconda.org/conda-forge/ harfbuzz 14.2.0 h6083320_0 2.2 MiB conda https://conda.anaconda.org/conda-forge/ icu 78.3 h33c6efd_0 12.1 MiB conda https://conda.anaconda.org/conda-forge/ keyutils 1.6.3 hb9d3cd8_0 130.9 KiB conda https://conda.anaconda.org/conda-forge/ kiwisolver 1.5.0 py312h0a2e395_0 75.3 KiB conda https://conda.anaconda.org/conda-forge/ krb5 1.22.2 ha1258a1_0 1.3 MiB conda https://conda.anaconda.org/conda-forge/ lcms2 2.19 h0c24ade_0 244.7 KiB conda https://conda.anaconda.org/conda-forge/ ld_impl_linux-64 2.45.1 default_hbd61a6d_102 710.9 KiB conda https://conda.anaconda.org/conda-forge/ lerc 4.1.0 hdb68285_0 255.4 KiB conda https://conda.anaconda.org/conda-forge/ libblas 3.11.0 6_h4a7cf45_openblas 18.2 KiB conda https://conda.anaconda.org/conda-forge/ libbrotlicommon 1.2.0 hb03c661_1 78.1 KiB conda https://conda.anaconda.org/conda-forge/ libbrotlidec 1.2.0 hb03c661_1 33.8 KiB conda https://conda.anaconda.org/conda-forge/ libbrotlienc 1.2.0 hb03c661_1 291.4 KiB conda https://conda.anaconda.org/conda-forge/ libcblas 3.11.0 6_h0358290_openblas 18.2 KiB conda https://conda.anaconda.org/conda-forge/ libclang13 22.1.4 default_h746c552_0 12.2 MiB conda https://conda.anaconda.org/conda-forge/ libcups 2.3.3 h7a8fb5f_6 4.3 MiB conda https://conda.anaconda.org/conda-forge/ libdeflate 1.25 h17f619e_0 71.8 KiB conda https://conda.anaconda.org/conda-forge/ libdrm 2.4.125 hb03c661_1 303.5 KiB conda https://conda.anaconda.org/conda-forge/ libedit 3.1.20250104 pl5321h7949ede_0 131.5 KiB conda https://conda.anaconda.org/conda-forge/ libegl 1.7.0 ha4b6fd6_2 43.8 KiB conda https://conda.anaconda.org/conda-forge/ libegl-devel 1.7.0 ha4b6fd6_2 29.7 KiB conda https://conda.anaconda.org/conda-forge/ libexpat 2.7.5 hecca717_0 74.8 KiB conda https://conda.anaconda.org/conda-forge/ libffi 3.5.2 h3435931_0 57.2 KiB conda https://conda.anaconda.org/conda-forge/ libfreetype 2.14.3 ha770c72_0 7.9 KiB conda https://conda.anaconda.org/conda-forge/ libfreetype6 2.14.3 h73754d4_0 375.6 KiB conda https://conda.anaconda.org/conda-forge/ libgcc 15.2.0 he0feb66_18 1017.4 KiB conda https://conda.anaconda.org/conda-forge/ libgcc-ng 15.2.0 h69a702a_18 26.9 KiB conda https://conda.anaconda.org/conda-forge/ libgfortran 15.2.0 h69a702a_18 26.9 KiB conda https://conda.anaconda.org/conda-forge/ libgfortran5 15.2.0 h68bc16d_18 2.4 MiB conda https://conda.anaconda.org/conda-forge/ libgl 1.7.0 ha4b6fd6_2 131.6 KiB conda https://conda.anaconda.org/conda-forge/ libgl-devel 1.7.0 ha4b6fd6_2 111.2 KiB conda https://conda.anaconda.org/conda-forge/ libglib 2.88.0 h6705ce6_0 4.6 MiB conda https://conda.anaconda.org/conda-forge/ libglvnd 1.7.0 ha4b6fd6_2 129.4 KiB conda https://conda.anaconda.org/conda-forge/ libglx 1.7.0 ha4b6fd6_2 73.7 KiB conda https://conda.anaconda.org/conda-forge/ libglx-devel 1.7.0 ha4b6fd6_2 25.8 KiB conda https://conda.anaconda.org/conda-forge/ libgomp 15.2.0 he0feb66_18 589.1 KiB conda https://conda.anaconda.org/conda-forge/ libiconv 1.18 h3b78370_2 771.7 KiB conda https://conda.anaconda.org/conda-forge/ libjpeg-turbo 3.1.4.1 hb03c661_0 619 KiB conda https://conda.anaconda.org/conda-forge/ liblapack 3.11.0 6_h47877c9_openblas 18.2 KiB conda https://conda.anaconda.org/conda-forge/ libllvm22 22.1.4 hf7376ad_0 42.2 MiB conda https://conda.anaconda.org/conda-forge/ liblzma 5.8.3 hb03c661_0 110.8 KiB conda https://conda.anaconda.org/conda-forge/ liblzma-devel 5.8.3 hb03c661_0 479.9 KiB conda https://conda.anaconda.org/conda-forge/ libnsl 2.0.1 hb9d3cd8_1 32.9 KiB conda https://conda.anaconda.org/conda-forge/ libntlm 1.8 hb9d3cd8_0 32.6 KiB conda https://conda.anaconda.org/conda-forge/ libopenblas 0.3.32 pthreads_h94d23a6_0 5.7 MiB conda https://conda.anaconda.org/conda-forge/ libopengl 1.7.0 ha4b6fd6_2 49.6 KiB conda https://conda.anaconda.org/conda-forge/ libpciaccess 0.18 hb9d3cd8_0 27.8 KiB conda https://conda.anaconda.org/conda-forge/ libpng 1.6.58 h421ea60_0 310.3 KiB conda https://conda.anaconda.org/conda-forge/ libpq 18.3 h9abb657_0 2.7 MiB conda https://conda.anaconda.org/conda-forge/ libsqlite 3.53.0 hf4e2dac_0 936.4 KiB conda https://conda.anaconda.org/conda-forge/ libstdcxx 15.2.0 h934c35e_18 5.6 MiB conda https://conda.anaconda.org/conda-forge/ libstdcxx-ng 15.2.0 hdf11a46_18 26.9 KiB conda https://conda.anaconda.org/conda-forge/ libtiff 4.7.1 h9d88235_1 425.1 KiB conda https://conda.anaconda.org/conda-forge/ libuuid 2.42 h5347b49_0 39.4 KiB conda https://conda.anaconda.org/conda-forge/ libvulkan-loader 1.4.341.0 h5279c79_0 195.1 KiB conda https://conda.anaconda.org/conda-forge/ libwebp-base 1.6.0 hd42ef1d_0 419 KiB conda https://conda.anaconda.org/conda-forge/ libxcb 1.17.0 h8a09558_0 386.6 KiB conda https://conda.anaconda.org/conda-forge/ libxcrypt 4.4.36 hd590300_1 98 KiB conda https://conda.anaconda.org/conda-forge/ libxkbcommon 1.13.1 hca5e8e5_0 818.3 KiB conda https://conda.anaconda.org/conda-forge/ libxml2 2.15.3 h49c6c72_0 45.7 KiB conda https://conda.anaconda.org/conda-forge/ libxml2-16 2.15.3 hca6bf5a_0 546.7 KiB conda https://conda.anaconda.org/conda-forge/ libxslt 1.1.43 h711ed8c_1 239.7 KiB conda https://conda.anaconda.org/conda-forge/ libzlib 1.3.2 h25fd6f3_2 62.1 KiB conda https://conda.anaconda.org/conda-forge/ matplotlib 3.10.9 py312h7900ff3_0 17.4 KiB conda https://conda.anaconda.org/conda-forge/ matplotlib-base 3.10.9 py312he3d6523_0 7.9 MiB conda https://conda.anaconda.org/conda-forge/ munkres 1.1.4 pyhd8ed1ab_1 15.5 KiB conda https://conda.anaconda.org/conda-forge/ ncurses 6.6 hdb14827_0 897.4 KiB conda https://conda.anaconda.org/conda-forge/ numpy 2.4.3 py312h33ff503_0 8.4 MiB conda https://conda.anaconda.org/conda-forge/ openjpeg 2.5.4 h55fea9a_0 347.1 KiB conda https://conda.anaconda.org/conda-forge/ openldap 2.6.13 hbde042b_0 767.7 KiB conda https://conda.anaconda.org/conda-forge/ openssl 3.6.2 h35e630c_0 3 MiB conda https://conda.anaconda.org/conda-forge/ packaging 26.2 pyhc364b38_0 89.4 KiB conda https://conda.anaconda.org/conda-forge/ pcre2 10.47 haa7fec5_0 1.2 MiB conda https://conda.anaconda.org/conda-forge/ pillow 12.2.0 py312h50c33e8_0 1015.2 KiB conda https://conda.anaconda.org/conda-forge/ pixman 0.46.4 h54a6638_1 440.4 KiB conda https://conda.anaconda.org/conda-forge/ pthread-stubs 0.4 hb9d3cd8_1002 8.1 KiB conda https://conda.anaconda.org/conda-forge/ pyparsing 3.3.2 pyhcf101f3_0 108.3 KiB conda https://conda.anaconda.org/conda-forge/ pyside6 6.11.0 py312h50ac2ff_2 12.7 MiB conda https://conda.anaconda.org/conda-forge/ python 3.12.0 hab00c5b_0_cpython 30.6 MiB conda https://conda.anaconda.org/conda-forge/ python-dateutil 2.9.0.post0 pyhe01879c_2 227.8 KiB conda https://conda.anaconda.org/conda-forge/ python_abi 3.12 8_cp312 6.8 KiB conda https://conda.anaconda.org/conda-forge/ qhull 2020.2 h434a139_5 540 KiB conda https://conda.anaconda.org/conda-forge/ qt6-main 6.11.0 pl5321h16c4a6b_4 57.2 MiB conda https://conda.anaconda.org/conda-forge/ readline 8.3 h853b02a_0 337 KiB conda https://conda.anaconda.org/conda-forge/ six 1.17.0 pyhe01879c_1 18 KiB conda https://conda.anaconda.org/conda-forge/ tk 8.6.13 noxft_h366c992_103 3.1 MiB conda https://conda.anaconda.org/conda-forge/ tornado 6.5.5 py312h4c3975b_0 839.5 KiB conda https://conda.anaconda.org/conda-forge/ tzdata 2025c hc9c84f9_1 116.3 KiB conda https://conda.anaconda.org/conda-forge/ unicodedata2 17.0.1 py312h4c3975b_0 401 KiB conda https://conda.anaconda.org/conda-forge/ wayland 1.25.0 hd6090a7_0 326.3 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util 0.4.1 h4f16b4b_2 20.3 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util-cursor 0.1.6 hb03c661_0 20.3 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util-image 0.4.0 hb711507_2 24 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util-keysyms 0.4.1 hb711507_0 14 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util-renderutil 0.3.10 hb711507_0 16.6 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util-wm 0.4.2 hb711507_0 50.5 KiB conda https://conda.anaconda.org/conda-forge/ xkeyboard-config 2.47 hb03c661_0 389.9 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libice 1.1.2 hb9d3cd8_0 57.3 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libsm 1.2.6 he73a12e_0 26.9 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libx11 1.8.13 he1eb515_0 820 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxau 1.0.12 hb03c661_1 15 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxcomposite 0.4.7 hb03c661_0 14.1 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxcursor 1.2.3 hb9d3cd8_0 31.8 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxdamage 1.1.6 hb9d3cd8_0 12.9 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxdmcp 1.1.5 hb03c661_1 20.1 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxext 1.3.7 hb03c661_0 49.1 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxfixes 6.0.2 hb03c661_0 19.6 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxi 1.8.2 hb9d3cd8_0 46.1 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxrandr 1.5.5 hb03c661_0 29.7 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxrender 0.9.12 hb9d3cd8_0 32.2 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxtst 1.2.5 hb9d3cd8_3 32 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxxf86vm 1.1.7 hb03c661_0 18.3 KiB conda https://conda.anaconda.org/conda-forge/ xorg-xorgproto 2025.1 hb03c661_0 556.7 KiB conda https://conda.anaconda.org/conda-forge/ xz 5.8.3 ha02ee65_0 23.8 KiB conda https://conda.anaconda.org/conda-forge/ xz-gpl-tools 5.8.3 ha02ee65_0 33.4 KiB conda https://conda.anaconda.org/conda-forge/ xz-tools 5.8.3 hb03c661_0 93.7 KiB conda https://conda.anaconda.org/conda-forge/ zlib-ng 2.3.3 hceb46e0_1 119.7 KiB conda https://conda.anaconda.org/conda-forge/ zstd 1.5.7 hb78ec9c_6 587.3 KiB conda https://conda.anaconda.org/conda-forge/
Exercise: Try installing the package mtrf from Conda-Forge. What does the error message say?
Solution
pixi add mtrfError: × failed to solve requirements of environment 'default' for platform 'linux- │ 64' ├─▶ × failed to solve the environment │ ╰─▶ Cannot solve the request because of: No candidates were found for mtrf *.
Exercise: Install the mtrf package from --pypi.
Solution
pixi add --pypi mtrf✔ Added mtrf >=2.1.2, <3 Added these as pypi-dependencies.
Exercise: Open the pixi.toml file in VSCode and observe how the Conda-Forge and PyPI dependencies are listed separately.
NOTE: The pixi.toml file also contains other (user specific) information like author and platforms.
Solution
Content of pixi.toml:
[workspace]
authors = ["atleer <atle.rimehaug@gmail.com>"]
channels = ["conda-forge"]
name = "my_project"
platforms = ["linux-64"]
version = "0.1.0"
[tasks]
[dependencies]
python = "==3.12"
numpy = ">=2.4.3,<3"
matplotlib = ">=3.10.9,<4"
[pypi-dependencies]
mtrf = ">=2.1.2, <3"Section 3: Sharing and Reproducing Environments
Background
Pixi keeps track of all the dependencies we specify in our pixi.toml file.
At the same time, it is keeping track of all packages in the virtual environment (including the dependencies of our dependencies) in the pixi.lock file.
The lock file allows us to exactly reproduce the pixi environment in a different directory or even on a different machine by simply copying the pixi.lock file and running pixi install.
Exercises
In the following exercises, you’ll reproduce the current pixi environment from the pixi.lock file.
Here are the commands you need to know:
| Code | Description |
|---|---|
mkdir new_dir/ |
Create the directory new_dir/ |
cp file.txt new_dir/ |
Copy file.txt to new_dir/ (Linux/MacOS) |
copy file.txt new_dir/ |
Copy file.txt to new_dir/ (Windows) |
cd new_dir |
Change the directory to new_dir |
cd .. |
Change the directory to the parent of the current directory |
pixi install |
Install the environment from pixi.lock |
Exercise: Create a new directory called reproduce/ and copy pixi.toml and pixi.lock to this location. You can either use your file explorer or the terminal commands mkdir and cp.
Solution
mkdir /tmp/reproduce
cp pixi.toml /tmp/reproduce
cp pixi.lock /tmp/reproduceExercise: Move to the new reproduce/ directory and run pixi install to reproduce the environment there.
Solution
cd /tmp/reproduce
pixi installWARN Using local manifest /tmp/my_project/pixi.toml rather than /home/atleeri/repositories/learning_platform/new-learning-platform/pixi.toml from environment variable `PIXI_PROJECT_MANIFEST` ✔ The default environment has been installed.
Exercise: Run pixi list and check the installed version of numpy and ensure it matches the version in the original environment
Solution
pixi listWARN Using local manifest /tmp/my_project/pixi.toml rather than /home/atleeri/repositories/learning_platform/new-learning-platform/pixi.toml from environment variable `PIXI_PROJECT_MANIFEST` Package Version Build Size Kind Source _openmp_mutex 4.5 20_gnu 28.3 KiB conda https://conda.anaconda.org/conda-forge/ alsa-lib 1.2.15.3 hb03c661_0 571 KiB conda https://conda.anaconda.org/conda-forge/ array_api_compat 1.14.0 196.8 KiB pypi array_api_compat-1.14.0-py3-none-any.whl brotli 1.2.0 hed03a55_1 19.6 KiB conda https://conda.anaconda.org/conda-forge/ brotli-bin 1.2.0 hb03c661_1 20.5 KiB conda https://conda.anaconda.org/conda-forge/ bzip2 1.0.8 hda65f42_9 254.1 KiB conda https://conda.anaconda.org/conda-forge/ ca-certificates 2026.4.22 hbd8a1cb_0 128 KiB conda https://conda.anaconda.org/conda-forge/ cairo 1.18.4 he90730b_1 966.3 KiB conda https://conda.anaconda.org/conda-forge/ contourpy 1.3.3 py312h0a2e395_4 312.9 KiB conda https://conda.anaconda.org/conda-forge/ cycler 0.12.1 pyhcf101f3_2 14.4 KiB conda https://conda.anaconda.org/conda-forge/ cyrus-sasl 2.1.28 hac629b4_1 205.2 KiB conda https://conda.anaconda.org/conda-forge/ dbus 1.16.2 h24cb091_1 437.2 KiB conda https://conda.anaconda.org/conda-forge/ double-conversion 3.4.0 hecca717_0 70.1 KiB conda https://conda.anaconda.org/conda-forge/ font-ttf-dejavu-sans-mono 2.37 hab24e00_0 388.1 KiB conda https://conda.anaconda.org/conda-forge/ font-ttf-inconsolata 3.000 h77eed37_0 94.3 KiB conda https://conda.anaconda.org/conda-forge/ font-ttf-source-code-pro 2.038 h77eed37_0 684.4 KiB conda https://conda.anaconda.org/conda-forge/ font-ttf-ubuntu 0.83 h77eed37_3 1.5 MiB conda https://conda.anaconda.org/conda-forge/ fontconfig 2.17.1 h27c8c51_0 264.4 KiB conda https://conda.anaconda.org/conda-forge/ fonts-conda-ecosystem 1 0 3.6 KiB conda https://conda.anaconda.org/conda-forge/ fonts-conda-forge 1 hc364b38_1 4 KiB conda https://conda.anaconda.org/conda-forge/ fonttools 4.62.1 py312h8a5da7c_0 2.8 MiB conda https://conda.anaconda.org/conda-forge/ freetype 2.14.3 ha770c72_0 169.8 KiB conda https://conda.anaconda.org/conda-forge/ graphite2 1.3.14 hecca717_2 97.3 KiB conda https://conda.anaconda.org/conda-forge/ harfbuzz 14.2.0 h6083320_0 2.2 MiB conda https://conda.anaconda.org/conda-forge/ icu 78.3 h33c6efd_0 12.1 MiB conda https://conda.anaconda.org/conda-forge/ keyutils 1.6.3 hb9d3cd8_0 130.9 KiB conda https://conda.anaconda.org/conda-forge/ kiwisolver 1.5.0 py312h0a2e395_0 75.3 KiB conda https://conda.anaconda.org/conda-forge/ krb5 1.22.2 ha1258a1_0 1.3 MiB conda https://conda.anaconda.org/conda-forge/ lcms2 2.19 h0c24ade_0 244.7 KiB conda https://conda.anaconda.org/conda-forge/ ld_impl_linux-64 2.45.1 default_hbd61a6d_102 710.9 KiB conda https://conda.anaconda.org/conda-forge/ lerc 4.1.0 hdb68285_0 255.4 KiB conda https://conda.anaconda.org/conda-forge/ libblas 3.11.0 6_h4a7cf45_openblas 18.2 KiB conda https://conda.anaconda.org/conda-forge/ libbrotlicommon 1.2.0 hb03c661_1 78.1 KiB conda https://conda.anaconda.org/conda-forge/ libbrotlidec 1.2.0 hb03c661_1 33.8 KiB conda https://conda.anaconda.org/conda-forge/ libbrotlienc 1.2.0 hb03c661_1 291.4 KiB conda https://conda.anaconda.org/conda-forge/ libcblas 3.11.0 6_h0358290_openblas 18.2 KiB conda https://conda.anaconda.org/conda-forge/ libclang13 22.1.4 default_h746c552_0 12.2 MiB conda https://conda.anaconda.org/conda-forge/ libcups 2.3.3 h7a8fb5f_6 4.3 MiB conda https://conda.anaconda.org/conda-forge/ libdeflate 1.25 h17f619e_0 71.8 KiB conda https://conda.anaconda.org/conda-forge/ libdrm 2.4.125 hb03c661_1 303.5 KiB conda https://conda.anaconda.org/conda-forge/ libedit 3.1.20250104 pl5321h7949ede_0 131.5 KiB conda https://conda.anaconda.org/conda-forge/ libegl 1.7.0 ha4b6fd6_2 43.8 KiB conda https://conda.anaconda.org/conda-forge/ libegl-devel 1.7.0 ha4b6fd6_2 29.7 KiB conda https://conda.anaconda.org/conda-forge/ libexpat 2.7.5 hecca717_0 74.8 KiB conda https://conda.anaconda.org/conda-forge/ libffi 3.5.2 h3435931_0 57.2 KiB conda https://conda.anaconda.org/conda-forge/ libfreetype 2.14.3 ha770c72_0 7.9 KiB conda https://conda.anaconda.org/conda-forge/ libfreetype6 2.14.3 h73754d4_0 375.6 KiB conda https://conda.anaconda.org/conda-forge/ libgcc 15.2.0 he0feb66_18 1017.4 KiB conda https://conda.anaconda.org/conda-forge/ libgcc-ng 15.2.0 h69a702a_18 26.9 KiB conda https://conda.anaconda.org/conda-forge/ libgfortran 15.2.0 h69a702a_18 26.9 KiB conda https://conda.anaconda.org/conda-forge/ libgfortran5 15.2.0 h68bc16d_18 2.4 MiB conda https://conda.anaconda.org/conda-forge/ libgl 1.7.0 ha4b6fd6_2 131.6 KiB conda https://conda.anaconda.org/conda-forge/ libgl-devel 1.7.0 ha4b6fd6_2 111.2 KiB conda https://conda.anaconda.org/conda-forge/ libglib 2.88.0 h6705ce6_0 4.6 MiB conda https://conda.anaconda.org/conda-forge/ libglvnd 1.7.0 ha4b6fd6_2 129.4 KiB conda https://conda.anaconda.org/conda-forge/ libglx 1.7.0 ha4b6fd6_2 73.7 KiB conda https://conda.anaconda.org/conda-forge/ libglx-devel 1.7.0 ha4b6fd6_2 25.8 KiB conda https://conda.anaconda.org/conda-forge/ libgomp 15.2.0 he0feb66_18 589.1 KiB conda https://conda.anaconda.org/conda-forge/ libiconv 1.18 h3b78370_2 771.7 KiB conda https://conda.anaconda.org/conda-forge/ libjpeg-turbo 3.1.4.1 hb03c661_0 619 KiB conda https://conda.anaconda.org/conda-forge/ liblapack 3.11.0 6_h47877c9_openblas 18.2 KiB conda https://conda.anaconda.org/conda-forge/ libllvm22 22.1.4 hf7376ad_0 42.2 MiB conda https://conda.anaconda.org/conda-forge/ liblzma 5.8.3 hb03c661_0 110.8 KiB conda https://conda.anaconda.org/conda-forge/ liblzma-devel 5.8.3 hb03c661_0 479.9 KiB conda https://conda.anaconda.org/conda-forge/ libnsl 2.0.1 hb9d3cd8_1 32.9 KiB conda https://conda.anaconda.org/conda-forge/ libntlm 1.8 hb9d3cd8_0 32.6 KiB conda https://conda.anaconda.org/conda-forge/ libopenblas 0.3.32 pthreads_h94d23a6_0 5.7 MiB conda https://conda.anaconda.org/conda-forge/ libopengl 1.7.0 ha4b6fd6_2 49.6 KiB conda https://conda.anaconda.org/conda-forge/ libpciaccess 0.18 hb9d3cd8_0 27.8 KiB conda https://conda.anaconda.org/conda-forge/ libpng 1.6.58 h421ea60_0 310.3 KiB conda https://conda.anaconda.org/conda-forge/ libpq 18.3 h9abb657_0 2.7 MiB conda https://conda.anaconda.org/conda-forge/ libsqlite 3.53.0 hf4e2dac_0 936.4 KiB conda https://conda.anaconda.org/conda-forge/ libstdcxx 15.2.0 h934c35e_18 5.6 MiB conda https://conda.anaconda.org/conda-forge/ libstdcxx-ng 15.2.0 hdf11a46_18 26.9 KiB conda https://conda.anaconda.org/conda-forge/ libtiff 4.7.1 h9d88235_1 425.1 KiB conda https://conda.anaconda.org/conda-forge/ libuuid 2.42 h5347b49_0 39.4 KiB conda https://conda.anaconda.org/conda-forge/ libvulkan-loader 1.4.341.0 h5279c79_0 195.1 KiB conda https://conda.anaconda.org/conda-forge/ libwebp-base 1.6.0 hd42ef1d_0 419 KiB conda https://conda.anaconda.org/conda-forge/ libxcb 1.17.0 h8a09558_0 386.6 KiB conda https://conda.anaconda.org/conda-forge/ libxcrypt 4.4.36 hd590300_1 98 KiB conda https://conda.anaconda.org/conda-forge/ libxkbcommon 1.13.1 hca5e8e5_0 818.3 KiB conda https://conda.anaconda.org/conda-forge/ libxml2 2.15.3 h49c6c72_0 45.7 KiB conda https://conda.anaconda.org/conda-forge/ libxml2-16 2.15.3 hca6bf5a_0 546.7 KiB conda https://conda.anaconda.org/conda-forge/ libxslt 1.1.43 h711ed8c_1 239.7 KiB conda https://conda.anaconda.org/conda-forge/ libzlib 1.3.2 h25fd6f3_2 62.1 KiB conda https://conda.anaconda.org/conda-forge/ matplotlib 3.10.9 py312h7900ff3_0 17.4 KiB conda https://conda.anaconda.org/conda-forge/ matplotlib-base 3.10.9 py312he3d6523_0 7.9 MiB conda https://conda.anaconda.org/conda-forge/ mtrf 2.1.2 68.1 KiB pypi mtrf-2.1.2-py3-none-any.whl munkres 1.1.4 pyhd8ed1ab_1 15.5 KiB conda https://conda.anaconda.org/conda-forge/ ncurses 6.6 hdb14827_0 897.4 KiB conda https://conda.anaconda.org/conda-forge/ numpy 2.4.3 py312h33ff503_0 8.4 MiB conda https://conda.anaconda.org/conda-forge/ openjpeg 2.5.4 h55fea9a_0 347.1 KiB conda https://conda.anaconda.org/conda-forge/ openldap 2.6.13 hbde042b_0 767.7 KiB conda https://conda.anaconda.org/conda-forge/ openssl 3.6.2 h35e630c_0 3 MiB conda https://conda.anaconda.org/conda-forge/ packaging 26.2 pyhc364b38_0 89.4 KiB conda https://conda.anaconda.org/conda-forge/ pcre2 10.47 haa7fec5_0 1.2 MiB conda https://conda.anaconda.org/conda-forge/ pillow 12.2.0 py312h50c33e8_0 1015.2 KiB conda https://conda.anaconda.org/conda-forge/ pixman 0.46.4 h54a6638_1 440.4 KiB conda https://conda.anaconda.org/conda-forge/ pthread-stubs 0.4 hb9d3cd8_1002 8.1 KiB conda https://conda.anaconda.org/conda-forge/ pyparsing 3.3.2 pyhcf101f3_0 108.3 KiB conda https://conda.anaconda.org/conda-forge/ pyside6 6.11.0 py312h50ac2ff_2 12.7 MiB conda https://conda.anaconda.org/conda-forge/ python 3.12.0 hab00c5b_0_cpython 30.6 MiB conda https://conda.anaconda.org/conda-forge/ python-dateutil 2.9.0.post0 pyhe01879c_2 227.8 KiB conda https://conda.anaconda.org/conda-forge/ python_abi 3.12 8_cp312 6.8 KiB conda https://conda.anaconda.org/conda-forge/ qhull 2020.2 h434a139_5 540 KiB conda https://conda.anaconda.org/conda-forge/ qt6-main 6.11.0 pl5321h16c4a6b_4 57.2 MiB conda https://conda.anaconda.org/conda-forge/ readline 8.3 h853b02a_0 337 KiB conda https://conda.anaconda.org/conda-forge/ six 1.17.0 pyhe01879c_1 18 KiB conda https://conda.anaconda.org/conda-forge/ tk 8.6.13 noxft_h366c992_103 3.1 MiB conda https://conda.anaconda.org/conda-forge/ tornado 6.5.5 py312h4c3975b_0 839.5 KiB conda https://conda.anaconda.org/conda-forge/ tzdata 2025c hc9c84f9_1 116.3 KiB conda https://conda.anaconda.org/conda-forge/ unicodedata2 17.0.1 py312h4c3975b_0 401 KiB conda https://conda.anaconda.org/conda-forge/ wayland 1.25.0 hd6090a7_0 326.3 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util 0.4.1 h4f16b4b_2 20.3 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util-cursor 0.1.6 hb03c661_0 20.3 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util-image 0.4.0 hb711507_2 24 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util-keysyms 0.4.1 hb711507_0 14 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util-renderutil 0.3.10 hb711507_0 16.6 KiB conda https://conda.anaconda.org/conda-forge/ xcb-util-wm 0.4.2 hb711507_0 50.5 KiB conda https://conda.anaconda.org/conda-forge/ xkeyboard-config 2.47 hb03c661_0 389.9 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libice 1.1.2 hb9d3cd8_0 57.3 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libsm 1.2.6 he73a12e_0 26.9 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libx11 1.8.13 he1eb515_0 820 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxau 1.0.12 hb03c661_1 15 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxcomposite 0.4.7 hb03c661_0 14.1 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxcursor 1.2.3 hb9d3cd8_0 31.8 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxdamage 1.1.6 hb9d3cd8_0 12.9 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxdmcp 1.1.5 hb03c661_1 20.1 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxext 1.3.7 hb03c661_0 49.1 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxfixes 6.0.2 hb03c661_0 19.6 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxi 1.8.2 hb9d3cd8_0 46.1 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxrandr 1.5.5 hb03c661_0 29.7 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxrender 0.9.12 hb9d3cd8_0 32.2 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxtst 1.2.5 hb9d3cd8_3 32 KiB conda https://conda.anaconda.org/conda-forge/ xorg-libxxf86vm 1.1.7 hb03c661_0 18.3 KiB conda https://conda.anaconda.org/conda-forge/ xorg-xorgproto 2025.1 hb03c661_0 556.7 KiB conda https://conda.anaconda.org/conda-forge/ xz 5.8.3 ha02ee65_0 23.8 KiB conda https://conda.anaconda.org/conda-forge/ xz-gpl-tools 5.8.3 ha02ee65_0 33.4 KiB conda https://conda.anaconda.org/conda-forge/ xz-tools 5.8.3 hb03c661_0 93.7 KiB conda https://conda.anaconda.org/conda-forge/ zlib-ng 2.3.3 hceb46e0_1 119.7 KiB conda https://conda.anaconda.org/conda-forge/ zstd 1.5.7 hb78ec9c_6 587.3 KiB conda https://conda.anaconda.org/conda-forge/
Section 4: Running Python Scripts with Pixi Environments
Background
So far, we used Pixi to install Python as well as some packages but we never ran any code. In this section we are going to run a very simple Python script that simply prints "Hello World!" and run it in the Pixi environment we created.
To do this we could use pixi shell to activate the environment (as we did before) and then run the environment. However, we can make things even simpler and use the pixi run command which combines activating the environment and running the script in a single step.
Exercises
| Code | Description |
|---|---|
pixi shell |
Activate the virtual environment |
python analyse.py |
Run the Python script analyze.py |
pixi run python analyze.py |
Run the Python script analyze.py in the current Pixi environment |
Exercise: Copy the code in the cell below and save it to a file called hello.py.
print("Hello World!")Hello World!Exercise: Use pixi shell to activate the virtual environment. Then, run python hello.py to run the Python script.
NOTE: If hello.py is not located in your current directory you must specify the full path, e.g. my_directory/hello.py.
Solution
pixi shell
python hello.pyHello World!Exercise: Now use pixi run to execute the Python script without having to activate the environment first.
Solution
pixi run python hello.pyHello World!Section 5: Demo: Managing Multiple Environments
One strength of Pixi is its ability to manage projects that require multiple environments. This can be useful for research steps with multiple computation steps (e.g. preprocessing, statistics, visualization) that have different, incompatible dependencies. Pixi has two different concepts that are relevant here: features and environments. A feature is simply a set of packages with a specific name and an environment is a collection of features.
For this demo, lets create a little mock example. We’ll use the packages cowsay and pyfiglet in two separate environments. While there is no actual dependency conflict between these packages, it illustrates how we can isolate different parts of our code with dedicated environments.
First, we add the packages cowsay and pyfiglet and use the -f flag to assign each to a specific feature. Here, the features are called cow and fig. If you run the code you may get errors saying that these features do not belong to any environment - you can ignore these errors for now.
!pixi add --pypi -q -f cow cowsay
!pixi add --pypi -q -f fig pyfiglet✔ Added cowsay Added these as pypi-dependencies. Added these only for feature: cow ✔ Added pyfiglet Added these as pypi-dependencies. Added these only for feature: fig
Let’s look at the content of pixi.toml.
The dependencies listed in [dependencies] will be available for every environment while those listed under the [feature] headings will only be available in the environments that use these features.
!cat /tmp/my_project/pixi.toml[workspace]
authors = ["atleer <atle.rimehaug@gmail.com>"]
channels = ["conda-forge"]
name = "my_project"
platforms = ["linux-64"]
version = "0.1.0"
[tasks]
[dependencies]
python = "==3.12"
numpy = ">=2.4.3,<3"
matplotlib = ">=3.10.9,<4"
[pypi-dependencies]
mtrf = ">=2.1.2, <3"
[feature.cow.pypi-dependencies]
cowsay = "*"
[feature.fig.pypi-dependencies]
pyfiglet = "*"To create the environments we create a new heading called [environments] that define each environment as a list of features:
[environments]
env1=["cow"]
env2=["fig"]Here, the environments are called env1 and env2 and contain the features "cow" and "fig" respectively.
Each environment could also contain multiple features and the same feature can be used in multiple environments.
Now we can run cowsay in the environment env1 and pyfiglet in the environment env2. We specify the environment for the run command using the -e flag.
!pixi run -q -e env1 cowsay -t "Hello World" ___________
| Hello World |
===========
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||!pixi run -q -e env2 pyfiglet "Hello World" _ _ _ _ __ __ _ _
| | | | ___| | | ___ \ \ / /__ _ __| | __| |
| |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` |
| _ | __/ | | (_) | \ V V / (_) | | | | (_| |
|_| |_|\___|_|_|\___/ \_/\_/ \___/|_| |_|\__,_|