Quicknotes on Python Poetry

Written by vikasz | Published 2021/05/05
Tech Story Tags: python | poetry | python-poetry | software-development | python-poetry-project | programming | coding | python-programming

TLDR Create a new Poetry project with the following directory structure: Creating Poetry Project. Deactivate the Python virtual environment and install a Python package (pip install) Uninstall a Python packages (glypip uninstall) Display the package information and lock the project dependencies. Update the dependencies according to the project's Python project's size: Glypip.pyproject.tomlfile: Glyphilev.py project.py. Unload the Python environment:glyphilepip. Uninstall the Python package:glypiphip uninstall.via the TL;DR App

Create a new Poetry project:
# poetry new <project-name>

# Ex:
poetry new rocketship
This creates a Poetry project with the following directory structure:
Activate the Python virtual environment:
cd ./rocketship
poetry shell
Deactivate the Python virtual environment:
exit
Install a Python package (
pip install
):
# poetry add <package_name>

# Ex:
poetry add requests
Uninstall a Python package (
pip uninstall
):
# poetry remove <package_name>

# Ex:
poetry remove requests
Installing dependencies:
poetry install
Display the package information:
poetry show
Lock the project dependencies:
poetry lock
Update the dependencies according to the 
pyproject.toml
 file:
poetry update
List the existing Python virtual environments associated with a Poetry project:
cd rocketship
poetry env list
Example:
Delete the Python environment:
# poetry env remove <python-environment-name>

# Ex:
poetry env remove rocketship-DKQKySEf-py3.8
Follow this space (Vikas Z's blog) for more on Python Poetry usage and hacks.
Also published on Hashnode.

Written by vikasz | AI/Deep Learning/NLP, DevOps/Automation
Published by HackerNoon on 2021/05/05