This is a short cheat-sheet with some of the most common commands to be used when managing a Python project with Poetry
Warning
If you have just installed Poetry, there is a fair chance that now is the perfect moment to configure it to create the virtual environments in each project’s folder (in a subfolder called .venv/, which can be added to the .gitignore file.
poetry config virtualenvs.in-project true
To create set up a new project you can use:
# If you want to create a new folder, from scratchpoetry new project-name# If the project exists and you want to set up poetrypoetry init
Poetry defines all its settings in a pyproject.toml, a file that is not exclusive to Poetry but actually complies with PEP 518. In this file, all dependencies and module info is gathered. To add a new dependency:
# If it is a runtime dependencypoetry add pandas# If it is a development dependencypoetry add -D black
To update the lockfile and install all dependencies, run: