Uv

Introduction

  • An extremely fast Python package and project manager, written in Rust.

  • A single tool to replace pip, pip-tools, pipx, poetry, pyenv, twine, virtualenv, and more.

Install & manage python version

  • uv python install: Install Python versions.

  • uv python list: View available Python versions.

uv python install 3.12

Create New Project & Virtual environment

uv init <project_name>
uv venv --python 3.12
source .venv/bin/activate

uv will create the following files:

.
β”œβ”€β”€ .python-version
β”œβ”€β”€ README.md
β”œβ”€β”€ main.py
└── pyproject.toml

  • The pyproject.toml contains metadata about your project:

  • It is similar with package.json

uv.lock

  • uv.lock is a cross-platform lockfile that contains exact information about your project's dependencies. Unlike the pyproject.toml which is used to specify the broad requirements of your project, the lockfile contains the exact resolved versions that are installed in the project environment. This file should be checked into version control, allowing for consistent and reproducible installations across machines.

  • Similar with package-lock.json

.python-version

The .python-version file contains the project's default Python version. This file tells uv which Python version to use when creating the project's virtual environment.

Managing Dependencies

  • There are many ways to install package, after adding package, pyproject.toml and uv.lock will be updated

  • uv is compatible to pip

Tool

  • Tools are Python packages that provide command-line interfaces.

  • Similar with npm install <package> -g

Docker file

Last updated

Was this helpful?