Skip to content

Basic Usage

Ensure you've got pixi set up. If running pixi doesn't show the help, see the getting started if it doesn't.

pixi

Initialize a new project and navigate to the project directory.

pixi init pixi-hello-world
cd pixi-hello-world

Add the dependencies you would like to use.

pixi add python

Create a file named hello_world.py in the directory and paste the following code into the file.

hello_world.py
def hello():
    print("Hello World, to the new revolution in package management.")

if __name__ == "__main__":
    hello()

Run the code inside the environment.

pixi run python hello_world.py

You can also put this run command in a task.

pixi task add hello python hello_world.py

After adding the task, you can run the task using its name.

pixi run hello

Use the shell command to activate the environment and start a new shell in there.

pixi shell
python
exit()

You've just learned the basic features of pixi:

  1. initializing a project
  2. adding a dependency.
  3. adding a task, and executing it.
  4. running a program.

Feel free to play around with what you just learned like adding more tasks, dependencies or code.

Happy coding!

Use pixi as a global installation tool#

Use pixi to install tools on your machine.

Some notable examples:

# Awesome cross shell prompt, huge tip when using pixi!
pixi global install starship

# Want to try a different shell?
pixi global install fish

# Install other prefix.dev tools
pixi global install rattler-build

# Install a linter you want to use in multiple projects.
pixi global install ruff

Using the --no-activation option#

When installing packages globally, you can use the --no-activation option to prevent the insertion of environment activation code into the installed executable scripts. This means that when you run the installed executable, it won't modify the PATH or CONDA_PREFIX environment variables beforehand.

Example:

# Install a package without inserting activation code
pixi global install ruff --no-activation

This option can be useful in scenarios where you want more control over the environment activation or if you're using the installed executables in contexts where automatic activation might interfere with other processes.

Use pixi in GitHub Actions#

You can use pixi in GitHub Actions to install dependencies and run commands. It supports automatic caching of your environments.

- uses: prefix-dev/setup-pixi@v0.5.1
- run: pixi run cowpy "Thanks for using pixi"

See the GitHub Actions for more details.