poetry install: Install from the Lockfile
Install exactly what the lockfile pins.
poetry install reads poetry.lock and installs the resolved dependencies into the project’s environment. It is the core dependency-restore step in a Poetry-based CI job.
What it does
Installs dependencies from poetry.lock (resolving and writing the lock first if it is missing). By default it also installs the project itself; flags control groups and whether the root package is installed.
Common usage
Terminal
poetry install
poetry install --no-root
poetry install --only main
poetry install --with dev --no-interactionCommon CI error: lockfile out of date
If pyproject.toml changed without re-locking, poetry install (with --no-update behavior) reports the lock is inconsistent. Run poetry lock to refresh it, then commit the updated lockfile.
Terminal
# Failure:
# pyproject.toml changed significantly since poetry.lock
# was last generated. Run `poetry lock` to fix the lock.
# Fix:
poetry lock
poetry installOptions
| Option | Does |
|---|---|
| --no-root | Do not install the project itself |
| --only GROUP | Install only the named group(s) |
| --with GROUP | Include an optional group |
| --without GROUP | Exclude a group |
| --sync | Remove packages not in the lock |
Related guides
poetry lock: Resolve and Write poetry.lockHow poetry lock resolves dependencies and writes poetry.lock without installing, the --no-update flag, and th…
poetry add: Add a Dependency and Re-lockHow poetry add installs a dependency, updates pyproject.toml and poetry.lock, the --group and --dev usage, an…
pip install -r: Install from requirements.txt in CIHow pip install -r installs every dependency from a requirements file, the flags that make it reproducible in…