# How to export requirements.txt from a uv project


If a deployment tool requires [requirements.txt](https://pydevtools.com/handbook/reference/requirements.md), generate it from [uv](https://pydevtools.com/handbook/reference/uv.md)'s `uv.lock`. Keep managing dependencies in [pyproject.toml](https://pydevtools.com/handbook/reference/pyproject.toml.md); regenerate the exported file whenever dependencies change.

## Prerequisites

- [uv installed](https://pydevtools.com/handbook/how-to/how-to-install-uv.md).
- An existing uv project with a current {{< term "lockfile" >}} (`uv.lock`). Run the commands from the directory containing `pyproject.toml`.

## Export the locked dependencies

```bash
uv export --locked --format requirements-txt -o requirements.txt
```

uv writes `requirements.txt` and prints its contents. The file includes exact dependency versions and hashes; `--locked` fails if `uv.lock` needs updating. Resolve that mismatch with the project's normal [lockfile update workflow](https://pydevtools.com/handbook/how-to/how-to-use-a-uv-lockfile-for-reproducible-python-environments.md) before exporting again.

The default export includes the project's default [dependency groups](https://pydevtools.com/handbook/explanation/what-are-optional-dependencies-and-dependency-groups.md), normally `dev`. A packaged project also appears as `-e .`, an [editable install](https://pydevtools.com/handbook/explanation/what-is-an-editable-install.md) of the current directory. A bare project without a build system does not need that entry.

## Export dependencies for deployment

To omit all default groups and the project itself:

```bash
uv export --locked --no-default-groups --no-emit-project --format requirements-txt -o requirements.txt
```

The rewritten file contains the project's runtime dependencies, including {{< term "transitive-dependency" "transitive dependencies" >}}, without the root project's `-e .` entry. Use this when the deployment system handles application code separately. `--no-emit-project` retains the project's dependencies; it does not remove other local path dependencies.

`--no-dev` excludes only the `dev` group. Use `--no-default-groups` when production must exclude every configured default group.

## Include a named group

If the project declares a `test` group, export runtime dependencies plus that group:

```bash
uv export --locked --no-default-groups --group test --no-emit-project --format requirements-txt -o requirements-test.txt
```

uv writes and prints `requirements-test.txt` with the runtime and test dependencies. Replace `test` with the group's name in `pyproject.toml`; optional extras use `--extra` instead.

## Keep hashes and platform conditions

Exports include hashes by default. Keep them for [hash-checked installs](https://pydevtools.com/handbook/how-to/how-to-pin-dependencies-with-hashes-in-uv.md); add `--no-hashes` only if the receiving tool cannot parse them.

Dependencies with platform or Python conditions retain environment markers, such as `; sys_platform == 'win32'`. The installer selects matching entries on the target machine. This preserves the lockfile's supported environments; it does not make an unsupported dependency work on every platform.
