Python's Poetry

Prerequisites

First of all install pip and user pip to install pipx. From then on, use only pipx

install pip tools

py -m pip install --user pip-tools

# upgrade pip
py -m pip install --upgrade pip

install pipx

py -m pip install --user pipx

# adds executables to global path so you can call them without py -m ...
py -m pipx ensurepath
# close and reopen console

install poetry through pipx

py -m pipx install --user poetry

Usage

Init a project & add dependencies

Go to your project’s folder and set up poetry

# this creates a `.toml` file with configuration
poetry init

# if problems on init
poetry config virtualenvs.use-poetry-python true

create a README file

2 > README.md

open your pyproject.toml and there you need something like this, where this ‘hello’ is the one you use to run the project

[tool.poetry.scripts]
file-enlarger = "FileEnlarger:main"

add dependencies

poetry add {package_name}

Virtual envs

create virtual env for the project

# you need to have a README.md on the project's root
poetry install

enter into virtual env

poetry env activate

# activate or create new virtualenv for current project
poetry env use {other_env}

see active env

poetry env info

Build and run

build project

poetry build

install and run a project through poetry

# this works through pyproject.toml's conf
poetry install

execute

poetry run hello

Use poetry env from Visual Studio

Do the following & copy the result

poetry env info --path

Click on python’s version button > Agregar entorno… > Entorno existente > Entorno * > Personalizado

Pegar allí la ruta previa que has copiado y seleccionar el correspondiente.
Añadirle descripción (que será el nombre para identificarlo)
Seleccionar ese y darle a Run (F5)
Con eso ya VS debería coger y funcionar con las dependencias instaladas por poetry

What to do if pipx is broken

You can use pip

py -3.14 -m pip install --user --upgrade pip
py -3.14 -m pip install --user poetry
py -3.14 -m poetry --version

# if you add it to the path you may do
poetry --version