1. uv
uv1.1. Introduction
UV is a package manager that can replace the virtual environment manager such as conda and pyenv.
1.2. Installation
For mac user we simply execute:
curl -LsSf https://astral.sh/uv/install.sh | sh
We can execute uv --version to check whether uv is installed.
1.3. pyproject.toml and .python-version
pyproject.toml and .python-version1.3.1. uv sync from existing pyproject.toml
uv sync from existing pyproject.tomlWith the presence of
pyproject.tomlfor definition all dependencies and their version.python-versionfor definition ofpythonversion
we can execute
uv sync
to install all specified dependences. The directory .venv/ will be created to install everything needed to launch a virtual environment.
1.3.2. add specific package
The command
uv add package_name
will automatically update the pyproject.toml and uv.lock for for us (just like package.json and package.lock.json).
1.4. How to Set the name of the Virtual Environment Generated by a uv project
uv projectWe execute
uv project metadata --set name="agents"
It will set a value in pyproject.toml:
Now we can select agents from the python interpretor or from the kernels of jupyter notebook.
1.5. How to Generatge the good old requirement.txt if we still need it?
requirement.txt if we still need it?The file requirement.txt is not strictly necessary if we are using uv throughoutly. If someone is still using conda or pyenv for virtual environments, then export one for them:
uv pip compile pyproject.toml -o requirements.txt
2. Virtual Environment by uv
uv2.1. What uv sync does
uv sync doesuv automatically manages a virtual environment:
- ✅ Creates a
.venvdirectory (or custom location) - ✅ Installs all dependencies there
- ✅ Isolates your project from system Python
- ✅ You don't manually create it—uv sync does
The command
uv sync
automatically:
- Creates or updates
.venv/ - Installs all dependencies from pyproject.toml
- Ready to use
2.2. Execute python Script in uv virtual environment
uv virtual environmentpython something.py is now replaced by
uv run something.py















