# Poetry usage
Requires a [[Poetry setup]].
## Running python code
This syntax ensures you use the Poetry venv to run the code:
```shell
poetry run pytest # external tooling
poetry run python main ARGS # live code
poetry run my-script # defined in project.toml; no ARGS
```
## Using the venv's python in a shell
```shell
poetry shell
```
## Add new packages to manage
```bash
poetry add package-name
```
dev packages:
```shell
poetry add --group dev pytest ruff ty black pip-audit
```
## Install the dependencies in pyproject.toml
And create the poetry.lock file:
```bash
poetry install
```
If the poetry.lock file already exists, this installs exactly those dependencies.
## Update poetry.lock dependencies
```bash
poetry update
```
## Create a requirements.txt file
```shell
poetry export -f requirements.txt --output requirements.txt
```
## Install dependencies from a requirement.txt file
```shell
pip install poetry-add-requirements.txt
```
Now you can install the packages in the requirements.txt file:
```shell
poeareq
```