🚀 Exploring uv: The Fast, Modern Python Package & Environment Manager

Biswarup NahaBiswarup Naha
2 min read

📌 Published by Biswarup Naha


Recently, I dove into uv, a lightning-fast Python package and environment manager by Astral. What I found was a game-changer—especially for anyone juggling Python environments, CLI tools, or even one-off scripts.

Here’s a breakdown of what I learned.


⚙️ What is uv?

uv is a command-line tool that manages:

  • 🧰 Project dependencies and virtual environments

  • 📜 Single-file scripts with inline metadata

  • 🔧 CLI tools like ruff or black

  • 🐍 Python versions with pin and install

  • 💨 Faster pip, pip-tools, and virtualenv alternatives

It’s built in Rust and optimized for performance—everything runs blazingly fast.


🧪 My Hands-On Experience

🛠 1. Initialize a Project

uv init example
cd example
uv add ruff

Boom! It created a full project with .venv, lockfiles, and installed dependencies in milliseconds.


🧵 2. Run Single-File Scripts with Metadata

You can use uv on one-off scripts without needing a requirements.txt:

echo 'import requests; print(requests.get("https://astral.sh"))' > example.py
uv add --script example.py requests
uv run example.py

✅ Automatically manages dependencies and virtual environments.


⚙️ 3. Install CLI Tools (like pipx, but faster)

uv tool install ruff
ruff --version

Want to run a CLI tool temporarily? Try uvx:

uvx pycowsay "hello world!"

No clutter in your global Python environment!


🐍 4. Manage Python Versions

Install and switch between Python versions effortlessly:

uv python install 3.10 3.11 3.12
uv python pin 3.11
uv venv --python 3.12.0

🔥 Perfect for testing code across versions or isolating project environments.


📦 5. Use uv as a Drop-In pip Replacement

uv pip install -r requirements.txt
uv pip sync docs/requirements.txt

Or generate platform-independent lockfiles:

uv pip compile docs/requirements.in --universal --output-file docs/requirements.txt

📘 What I Learned

  • uv is ultra-fast and handles everything from projects to tools to scripts.

  • It removes the need for extra tools like virtualenv, pipx, pyenv, or poetry.

  • Inline metadata is a super cool feature for scripting.

  • It’s easy to install, understand, and use in day-to-day workflows.


💬 Final Thoughts

If you want a clean, modern, and supercharged way to manage Python projects or tools—give uv a try. It simplifies Python dev workflows in the best way possible.

🧡 I’m definitely using it in all my future scripts and apps!


📎 Links to Explore

0
Subscribe to my newsletter

Read articles from Biswarup Naha directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Biswarup Naha
Biswarup Naha