# pip to uv: a command cheatsheet


A quick-reference table for developers switching from [pip](https://pydevtools.com/handbook/reference/pip.md), venv, [pyenv](https://pydevtools.com/handbook/reference/pyenv.md), [pip-tools](https://pydevtools.com/handbook/reference/pip-tools.md), or [pipx](https://pydevtools.com/handbook/reference/pipx.md) to [uv](https://pydevtools.com/handbook/reference/uv.md). Each section maps an old command to its uv equivalent.

[Install uv](https://pydevtools.com/handbook/how-to/how-to-install-uv.md) first if you haven't already.

## Installing packages

| Before (pip) | After (uv) |
|---|---|
| `pip install requests` | `uv add requests` |
| `pip install requests==2.32.0` | `uv add "requests==2.32.0"` |
| `pip install "requests[socks]"` | `uv add "requests[socks]"` |
| `pip install -r requirements.txt` | `uv add -r requirements.txt` |
| `pip install -e .` | `uv sync` |

`uv add` writes the dependency to `pyproject.toml`, locks it in `uv.lock`, and installs it in one step. There is no need to maintain a separate requirements file.

For an existing project that already has a `pyproject.toml` and `uv.lock`, use `uv sync` to install everything from the lockfile. This is the equivalent of `pip install -r requirements.txt` in a locked project.

## Removing and inspecting packages

| Before (pip) | After (uv) |
|---|---|
| `pip uninstall requests` | `uv remove requests` |
| `pip list` | `uv pip list` |
| `pip show requests` | `uv pip show requests` |
| `pip check` | `uv pip check` |
| `pip freeze` | `uv pip freeze` |

`uv remove` updates `pyproject.toml` and `uv.lock` at the same time. The `uv pip` subcommands work against the active [virtual environment](https://pydevtools.com/handbook/explanation/what-is-a-virtual-environment.md) the same way pip does.

## Upgrading packages

| Before (pip) | After (uv) |
|---|---|
| `pip install --upgrade requests` | `uv lock --upgrade-package requests && uv sync` |
| `pip install --upgrade pip` | `uv self update` |

To upgrade a single dependency, `uv lock --upgrade-package requests` re-resolves that package to the latest allowed version and rewrites `uv.lock`. Follow it with `uv sync` to install the result. To upgrade all dependencies at once, run `uv lock --upgrade && uv sync`.

## Development dependencies

| Before (pip) | After (uv) |
|---|---|
| `pip install -r requirements-dev.txt` | `uv add --dev pytest ruff` |
| _(no built-in equivalent)_ | `uv sync --no-dev` |

uv tracks development dependencies in `pyproject.toml` under `[dependency-groups]`. Production installs that skip dev dependencies use `uv sync --no-dev`.

## Virtual environments

| Before (venv / virtualenv) | After (uv) |
|---|---|
| `python -m venv .venv` | `uv venv` |
| `source .venv/bin/activate` | _(not needed)_ |
| `deactivate` | _(not needed)_ |
| `python script.py` | `uv run script.py` |
| `python -m pytest` | `uv run pytest` |

`uv run` executes a command inside the project's virtual environment without requiring activation. If no virtual environment exists, `uv run` creates one automatically. This removes the most common source of "wrong Python" bugs.

> [!TIP]
> Shell activation still works if you prefer it. Run `uv venv` to create the environment and activate it the usual way. But `uv run` is the recommended workflow because it guarantees the environment is in sync with `uv.lock` before every command.

## Locking and compiling dependencies

| Before (pip-tools) | After (uv) |
|---|---|
| `pip-compile requirements.in` | `uv pip compile requirements.in` |
| `pip-compile --upgrade` | `uv pip compile --upgrade requirements.in` |
| `pip-sync requirements.txt` | `uv pip sync requirements.txt` |

These commands are useful for projects that still use the requirements.in/requirements.txt workflow. For new projects, the [native uv workflow](https://pydevtools.com/handbook/explanation/why-use-native-uv-over-uv-pip.md) with `pyproject.toml` and `uv.lock` replaces pip-tools entirely.

## Exporting to requirements.txt

| uv command | Result |
|---|---|
| `uv export --format requirements-txt` | Print locked dependencies as requirements.txt to stdout |
| `uv export --format requirements-txt > requirements.txt` | Write to a file |
| `uv export --format requirements-txt --no-dev` | Exclude dev dependencies |

Use `uv export` when a downstream tool or deployment process requires a `requirements.txt` file. The output comes from `uv.lock`, so versions are fully pinned.

## Python version management

| Before (pyenv) | After (uv) |
|---|---|
| `pyenv install 3.13` | `uv python install 3.13` |
| `pyenv local 3.13` | `uv python pin 3.13` |
| `pyenv versions` | `uv python list` |
| `pyenv global 3.13` | `uv python install 3.13 --default` |

`uv python pin` writes a `.python-version` file, and uv automatically downloads the requested version if it isn't already installed. This replaces pyenv for most workflows. See [how to switch from pyenv to uv](https://pydevtools.com/handbook/how-to/how-to-switch-from-pyenv-to-uv-for-managing-python-versions.md).

## Running CLI tools

| Before (pipx) | After (uv) |
|---|---|
| `pipx install ruff` | `uv tool install ruff` |
| `pipx run ruff check .` | `uvx ruff check .` |
| `pipx upgrade ruff` | `uv tool upgrade ruff` |
| `pipx uninstall ruff` | `uv tool uninstall ruff` |
| `pipx list` | `uv tool list` |

`uv tool install` and `uvx` isolate each tool in its own virtual environment, just like [pipx](https://pydevtools.com/handbook/reference/pipx.md). `uvx` runs a tool without installing it permanently. See the [uvx reference](https://pydevtools.com/handbook/reference/uvx.md).

## Starting a new project

| Before | After (uv) |
|---|---|
| `mkdir myproject && cd myproject && python -m venv .venv` | `uv init myproject && cd myproject` |

`uv init` creates a `pyproject.toml`, a `.python-version` file, and a virtual environment in one step. See [Create your first Python project](https://pydevtools.com/handbook/tutorial/create-your-first-python-project.md) for a full walkthrough.

## Running scripts with inline dependencies

No pip equivalent exists for this. uv supports [PEP 723](https://pydevtools.com/handbook/explanation/what-is-pep-723.md) inline script metadata:

```python {filename="plot.py"}
# /// script
# requires-python = ">=3.12"
# dependencies = [
#     "matplotlib",
# ]
# ///
import matplotlib.pyplot as plt

plt.plot([1, 2, 3], [1, 4, 9])
plt.savefig("plot.png")
```

```bash
uv run plot.py
```

uv reads the dependencies from the script header, creates a temporary environment, and runs the script. No `pyproject.toml` or virtual environment setup is needed.

## Learn More

- [How to migrate from requirements.txt to pyproject.toml with uv](https://pydevtools.com/handbook/how-to/migrate-requirements.txt.md) for step-by-step migration
- [How to migrate from Poetry to uv](https://pydevtools.com/handbook/how-to/how-to-migrate-from-poetry-to-uv.md) for projects using Poetry
- [Why use native uv commands instead of uv pip](https://pydevtools.com/handbook/explanation/why-use-native-uv-over-uv-pip.md) explains when to use `uv add` vs `uv pip install`
- [What is the difference between pip and uv?](https://pydevtools.com/handbook/explanation/whats-the-difference-between-pip-and-uv.md) for a deeper comparison
- [uv: A Complete Guide](https://pydevtools.com/handbook/explanation/uv-complete-guide.md) covers all uv workflows in detail
