1  Installation

There are several ways to install Python.

The current recommendation of this book is to use uv. uv is really fast and and comprehensive tool that can install and manage:

1.1 Install uv

You can install uv itself in a few different ways.

To directly install uv, you can use curl:

curl -LsSf https://astral.sh/uv/install.sh | sh

or wget:

wget -qO- https://astral.sh/uv/install.sh | sh

1.2 Upgrading uv

uv can upgrade itself:

uv self update

1.3 uv shell auto-completion

See here how to enable shell auto-completion for uv commands for your shell.

1.4 Install Python

To install Python using uv:

uv python install
Note

If you already have Python installed, e.g. using brew/homebrew or other package manager, you can skip this step, uv will find available Python installations on your system. Use uv python list to see all available Python installations, whether installed by uv or not.

1.5 Create a new project

To create a new project using uv:

uv init <project-name>
# or mkdir <project-name> && cd <project-name> && uv init

1.6 Install packages

uv add <package-name> <package-name2> ...

1.7 Install package as development dependency

Development dependencies are packages that are only needed for development, e.g. testing, linting, etc., but are not needed by the end user.

uv add --dev <package-name> <package-name2> ...

Reference: uv development dependencies

1.8 Install local pacckage in editable mode

If you are developing a package and want to install it so that changes to the package are immediately available in your project, you can install it in editable mode:

uv add --editable /path/to/package

Reference: uv editable dependencies

1.9 Update packages

Within a project, you can update all packages using:

uv lock --upgrade
uv sync

1.10 Remove packages

uv remove <package-name> <package-name2> ...

1.11 List project’s dependency tree

uv tree