This guide will help you set up a Python environment using uv, a fast Python package installer and resolver.
curl -LsSf https://astral.sh/uv/install.sh | shpip install uvCreate and populate a virtual environment with your dependencies:
# To ensure a safe setup, `uv sync` should work fine.
uv venv .venv --python 3.10
uv sync
# Check if the virtual environment is created with the name `.venv`.
# If not, explicitly create it using the first command.This will:
- Create a virtual environment in
.venv/ - Install packages from
requirements.txtand/orpyproject.toml
source .venv/bin/activate.venv\Scripts\activateuv add package_nameuv remove package_nameAfter adding or removing packages, update your requirements file:
# Generate/update requirements.txt from the current environment
uv pip freeze > requirements.txtFor more details on Python environment management with uv, check out the comprehensive guide at FloCode: Python Environments Again with uv.