poetry

**Poetry** - Python Dependency Management **Overview** Poetry is a modern tool for dependency management and packaging in Python. It provides a deterministic way to manage libraries, virtual environments, and project metadata in a single `pyproject.toml` file. **Why use Poetry?** - **Dependency Resolution**: It has a robust solver that handles conflicts (Version Hell) gracefully. - **Lockfile**: Generates `poetry.lock` to ensure all developers (and prod) use the exact same package versions. - **Packaging**: Makes publishing to PyPI trivial (`poetry publish`). **Basic Commands** ```bash **Start new project** poetry new my-app **Add a library** poetry add pandas **(Automatically updates pyproject.toml, installs to venv, updates lockfile)** **Developer Tools** poetry add --group dev black pytest **Run** poetry run python main.py **Shell** poetry shell ``` **vs Pip** - **Pip**: Just installs. Doesn't lock dependencies effectively (recursive dependencies often float). - **Poetry**: Full project management. It is the closest thing Python has to `npm` or `cargo`.

Go deeper with CFSGPT

Get AI-powered deep-dives, save terms, and run advanced simulations — free account.

Create Free Account