pythonpython-venvuv

How to add requirements.txt to uv environment


I am working with uv for the first time and have created a venv to manage my dependencies. Now, I'd like to install some dependencies from a requirements.txt file.

How can this be achieved with uv?

I already tried manually installing each requirement using uv pip install .... However, this gets tedious for a large list of requirements.


Solution

  • You can install the dependencies to the virtual environment managed by uv using:

    uv pip install -r requirements.txt
    

    When working with a project (application or library) managed by uv, the following command might be used instead:

    uv add -r requirements.txt
    

    This will also add the requirements to the project's pyproject.toml.