0% found this document useful (0 votes)
20 views2 pages

UV Python Package Manager Tutorial

UV is a high-performance Python package manager developed in Rust, designed to replace traditional tools like pip and venv, offering fast installation and dependency resolution. It supports project metadata through pyproject.toml, manages virtual environments, and provides features for adding/removing packages and viewing dependency trees. UV simplifies Python project management by combining multiple tools into a single, efficient solution.

Uploaded by

Balan Wv
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

UV Python Package Manager Tutorial

UV is a high-performance Python package manager developed in Rust, designed to replace traditional tools like pip and venv, offering fast installation and dependency resolution. It supports project metadata through pyproject.toml, manages virtual environments, and provides features for adding/removing packages and viewing dependency trees. UV simplifies Python project management by combining multiple tools into a single, efficient solution.

Uploaded by

Balan Wv
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

■ Introduction to UV (Python Package Manager)

UV is a high-performance Python package manager written in Rust. It replaces traditional


tools like pip, pip-tools, venv, and virtualenv. Developed by Astral.

■ Key Advantages
- Very fast installation and dependency resolution.

- Single tool for installing, locking, and syncing dependencies.

- Compatible with [Link] and [Link].

- Built-in virtual environment manager.

- Lock file support (similar to pip-tools).

- Cross-platform support (Windows, macOS, Linux).

■ Installation
On macOS:

brew install uv
Current version used: 0.7.11. Other OS installation methods available in official
documentation.

■ Traditional Setup with venv


mkdir with_venv && cd with_venv
python3 -m venv venv
source venv/bin/activate
pip install -r [Link]
pip freeze > [Link]
■ Using UV
Initialize a project:

mkdir with_uv && cd with_uv


uv init
This creates files like .gitignore, [Link], and a sample [Link]

■ [Link]
Defines project metadata and dependencies. Replaces [Link], [Link], and
[Link].

[project]
name = "uv-demo"
version = "0.1.0"
authors = [{ name = "John Doe", email = "john@[Link]" }]
description = "A demo UV project"
requires-python = ">=3.12"
dependencies = []
■ Managing Python Versions
uv python list
uv python install 3.12.11
■ Adding and Removing Packages
uv add requests
uv remove requests
■ Running Code
uv run [Link]
■ Viewing Dependency Tree
uv tree
■ Reproducing Environments
Copy [Link] and [Link], then run uv run [Link] to recreate environment.

■ Importing Existing [Link]


uv add -r [Link]
■ Summary of Concepts
Concept Description

[Link] Defines project metadata and dependencies


[Link] Stores exact dependency versions
uv run Executes scripts in managed environments
uv add/remove Installs or uninstalls dependencies
uv tree Displays dependency structure
uv python Manages Python versions

■ Conclusion
UV simplifies Python project management by combining pip, pip-tools, and venv. It offers
fast dependency resolution and standardized environment replication. A modern, fast, and
reliable alternative for Python environment management.

You might also like