> For the complete documentation index, see [llms.txt](https://docs.monarchlinux.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.monarchlinux.com/basics/shell-aliases/python-and-uv.md).

# Python and uv

See [Shell aliases and functions](https://docs.monarchlinux.com/basics/shell-aliases.md) for command discovery and personal overrides.

## Existing Python helpers

* `p`: invoke `python`.
* `pyreq`: run `pip install -r requirements.txt`. Activate the intended virtual environment first; this helper does not create one.
* `pv <version>`: configure the current project's Python version and a mise-managed `.venv`. This changes project mise configuration.

## Optional uv helpers

{% hint style="warning" %}
Upcoming: the shortcuts in this section are proposed in [PR #278](https://github.com/monarch-os/monarch/pull/278). They are not yet merged.
{% endhint %}

These functions load only when `uv` is already available on PATH. Loading your shell does not install or download anything. After installing uv, open a new terminal to load them. They do not replace `pyreq`, `pv`, pipx or your global Python selection.

### Create or activate an environment

`uvv` creates `.venv` in the current directory and activates it in the current shell. An existing environment is activated without recreation. If `.venv` exists without a readable `bin/activate`, it is left unchanged and the helper fails. It accepts no arguments; use `uv venv` directly for custom options.

```bash
uvv
uvreq
deactivate
```

### Install requirements

`uvreq` runs `uv pip install -r requirements.txt`. Additional arguments are forwarded unchanged; uv selects the target environment using its normal rules.

### Run scripts

`uvr` forwards to `uv run`, preserving your arguments:

```bash
uvr script.py 'an argument with spaces'
```

### Run Python with pwntools

`uvpwn` runs Python using `uv run --isolated --no-project --with pwntools python`. It does not discover or synchronize the current project. Arguments go to Python, not to uv.

```bash
uvpwn exploit.py --help
```

Invoking uv helpers can download Python or dependencies according to uv's own configuration. pwntools is resolved by uv, not pinned by Monarch. The wrappers preserve uv's exit status.
