python package dependencies and virtual environment management tool Poetry

What is Poetry?

--Manage python package dependencies --You can build a virtual environment dedicated to the project ( --You can specify the dependent python version --You can specify the dependent package version --A tool similar to ruby ​​bundle

Installation

https://python-poetry.org/docs/ Install with python script for mac

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -

Install using pip

pip install --user poetry

It is convenient to set

If you set as below, the virtual environment will be created under the project folder, and vscode can automatically identify the python environment, so vscode intellisense will work.

poetry config virtualenvs.in-project true

Introduced poetry in project

Create pyproject.toml (like ruby ​​gemfile) with the following command

poetry init

Add dependent packages

Install the dependent package into the virtual environment with the following command, and the dependent package is specified in pyproject.toml

poetry add pendulum
poetry add pendulum@^2.0.5  #If you also specify version
poetry add "pendulum>=2.0.5"  #If you also specify version

Install the dependent packages set in pyproject.toml, poetry.lock

poetry install

Update package

If you want to update all dependent packages

poetry update

If you want to update a specific package

poetry update fastapi

When you want to run code in a virtual environment

If you want to enter a virtual environment

poetry shell 

If you want to do something in a virtual environment

poetry run uvicorn main:app --reload

If you want to display package dependencies

poetry show --tree

reference

https://python-poetry.org/

Recommended Posts

python package dependencies and virtual environment management tool Poetry
venv: Python virtual environment management
Python package management tool personal summary
[Python] Anaconda environment construction (installation, startup, virtual environment, package management) Mac environment
Python virtual environment and packages on Ubuntu
Python installation and package management with pip
Python (Windows 10) Virtual Environment / Package with VS Code
python virtual environment Pipenv
virtual environment in python
Virtual environment with Python 3.6
Python: Creating a virtual environment (venv), starting and stopping
Build a python virtual environment with virtualenv and virtualenvwrapper
Building and enabling a python virtual environment, etc. (venv)
Build a python virtual environment with virtualenv and virtualenvwrapper
Manage Python runtime packages and development environment packages with Poetry
Python package management in IntelliJ
Python environment construction and TensorFlow
Building a Python virtual environment
python standard virtual environment venv
Building a Python virtual environment
Overview of Python virtual environment and how to create it
[2020/06 latest version] Basic usage of python dependency management tool poetry
A memorandum of understanding for the Python package management tool ez_setup
Virtual Environment Version Control Summary Python
Build python virtual environment with virtualenv
[Understanding in the figure] Management of Python virtual environment by Pipenv
Building a virtual environment with Python 3
Python environment construction (pyenv + poetry + pipx)
Visualize python package dependencies with graphviz
Docker environment update: add Python package
Python virtual environment construction (2017 version) pyenv and pyenv-virtualenv and virtualenv and virtualenv wrapper and pyvenv and venv
How to package and distribute Python scripts
About package management with conda and pip
Build Python3 and OpenCV environment on Ubuntu 18.04
Python environment tool comparison chart for Rubyist
[Python] Package and distribute your own modules
About the virtual environment of python version 3.7
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
Python App Dependent Package Management Best Practices
[Mac] Building a virtual environment for Python
Creating a python virtual environment on Windows
Python and machine learning environment construction (macOS)
[Python] PyPI package publishing procedure using poetry
Build a python virtual environment with pyenv
Clean python environment with pythonz and virtualenv
Add a Python virtual environment to VSCode
Windows + gVim + Poetry python development environment construction
Directory move tool to Python package (pycd)
Create a Django project and application in a Python virtual environment and start the server
Note: Start Anaconda, enter the Python virtual environment, and connect locally to MongoDB.
Python3 TensorFlow environment construction (Mac and pyenv virtualenv)
[Python] Python and security-② Port scanning tool made with Python
How to create a Python virtual environment (venv)
Recommended environment and usage when developing with Python
Ubuntu18.04.05 Creating a python virtual environment in LTS
Building a python environment with virtualenv and direnv
Python development flow using Poetry, Git and Docker
ffmpeg-Build a python environment and split the video
Create a virtual environment with conda in Python
Install the python package in an offline environment