If you’ve been in the Python world for a while, you know the "Environment Dance": create a venv, activate it, wait for pip to install 50 MB of packages, and hope your dependencies don't crash.
In 2026, we have a better way. Enter uv—the blazing-fast Python package manager that’s replacing pip, venv, and poetry all at once.
🚀 Why UV?
It’s Fast: Up to 100x faster than pip. We’re talking milliseconds, not minutes.
All-in-One: It manages your Python versions, your virtual environments, and your packages.
No More Activation: With uv run, you don't even need to remember the source bin/activate command anymore.
1. Installation
Installing uv is a one-time thing. It’s a standalone binary, so it doesn't even need Python to be installed yet!
On macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
On Windows:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
2. Creating an Environment
Forget python -m venv .venv. With uv, you just initialize your project:
uv init my-ai-project
cd my-ai-project
This creates a pyproject.toml (your project's heart) and a .venv folder automatically. Need a specific Python version? uv will download it for you if it's missing:
uv venv --python 3.12
3. Adding Packages (The Fast Way)
When we build our LangChain apps, we need several libraries. Instead of pip install, use:
uv add langchain langchain-openai python-dotenv
uv generates a uv.lock file instantly. This ensures that when your friend (or your server) runs your code, they get the exact same versions of every library.
4. Running Your Code
This is the "Magic Trick" of uv. You don't actually have to "activate" the environment to run your script.
Instead of:
source .venv/bin/activate && python app.py
Just do:
uv run app.py
uv will automatically find the virtual environment, ensure all packages are installed, and run your code. It’s cleaner, faster, and less prone to errors.
Top comments (0)