# How to use pip in a uv virtual environment

{{< callout type="warning" >}}
Only add [pip](https://pydevtools.com/handbook/reference/pip.md) to [uv](https://pydevtools.com/handbook/reference/uv.md) environments when specifically needed for compatibility with tools that directly call pip. For regular package management, continue using uv commands (`uv add`/`uv sync`), which offer better performance and reliability.
{{< /callout >}}

When working with [uv](https://pydevtools.com/handbook/reference/uv.md), you might occasionally need access to pip in your virtual environments, particularly when using tools that rely on pip directly, such as [Jupyter](https://pydevtools.com/handbook/how-to/jupyter-notebook-with-uv.md)'s `%pip` magic command.

## Add pip to a uv virtual environment

uv creates virtual environments without pip. If `.venv` already exists, install pip into it:

```bash
uv pip install pip
```

`uv pip install` targets the `.venv` in the current directory (or the one named by `$VIRTUAL_ENV`). The `--system` flag and `UV_SYSTEM_PYTHON=1` bypass that venv and aim at the system interpreter, which is usually externally managed and refuses the install.

For a fresh environment, seed pip at creation time:

```bash
uv venv --seed
```

`uv venv --seed` errors out when a `.venv` is already there. Add `--clear` to replace it, which discards everything currently installed.

## Keep pip through the next uv sync

In a project with a `pyproject.toml` and a `uv.lock`, `uv sync` removes every package the lockfile does not list. That includes pip and anything pip installed:

```console
$ uv sync
Resolved 5 packages in 1ms
Uninstalled 2 packages in 21ms
 - pip==26.2
 - six==1.17.0
```

`uv run --exact` prunes the same way. Plain `uv run` does not, so pip survives until the next explicit sync.

To keep pip permanently, let the lockfile own it:

```bash
uv add --dev pip
```

pip is then a tracked dev dependency, and `uv sync` reinstalls it instead of deleting it.

## Run pip commands

`uv run` executes inside the environment with no activation step:

```bash
uv run pip list
```

To use bare `pip` instead, activate the environment first:

```bash
source .venv/bin/activate
pip list
```
```powershell
.venv\Scripts\activate
pip list
```
