# Packages and virtual environments

> Use third-party Python packages with Elide: create a Python 3.13 virtual environment, install packages with uv, and set VIRTUAL_ENV so Elide imports them.

Elide does not install PyPI packages in 1.6.0. It imports packages from a Python 3.13 virtual environment named by
`VIRTUAL_ENV`.

| Source | What Elide does |
| --- | --- |
| `pyproject.toml` `[project] dependencies` | Nothing; `[project.scripts]` entry points run with `elide run` ([Python Toolchain](https://elide.help/docs/python-toolchain#run-project-scripts)) |
| `elide.pkl` `dependencies.pypi` | Accepts the declaration; `elide install` skips it ([reference](https://elide.help/docs/elide-pkl-reference#dependencies)) |
| `requirements.txt` | Nothing |
| `$VIRTUAL_ENV/lib/python3.13/site-packages` | Adds it to `sys.path` |

`elide install --ecosystems=pypi` prints `elide install: pypi installs are not available in this build` and exits `2`.

## Create a virtual environment

Create the environment with a Python 3.13 tool. With [uv](https://docs.astral.sh/uv/):

```bash
uv venv --python 3.13 .venv
uv pip install --python .venv/bin/python attrs
```

The environment's own interpreter is only used to install packages; Elide runs the code.

## Use it

```python
# app.py
import attrs


@attrs.define
class Point:
    x: int
    y: int


print(Point(1, 2))
```

```bash
VIRTUAL_ENV=.venv elide python app.py
```

```terminaloutput
Point(x=1, y=2)
```

Activating the environment sets `VIRTUAL_ENV` too:

```bash
source .venv/bin/activate
elide run app.py
```

Without `VIRTUAL_ENV`, the import fails with `ModuleNotFoundError: No module named 'attrs'`.

## Limits

- The environment must be Python 3.13: Elide reads `lib/python3.13/site-packages`.
- Pure-Python packages work. Some C extension modules do not load.
- pip is not bundled, so `elide python -m pip` fails; install with the environment's own tools.
