pipx

https://pipx.pypa.io/stable/

前置需求:Python 3.8+

Linux 安裝:

python3 -m pip install --user pipx
python3 -m pipx ensurepath
  • 安裝至 ~/.local/bin/pipx

macOS 安裝:

brew install pipx
pipx ensurepath
  • 安裝至 /opt/homebrew/bin/pipx

poetry

https://python-poetry.org/

先裝 pipx,再透過 pipx 安裝 poetry。

安裝:

pipx install poetry
  • Linux & macOS 皆安裝至 ~/.local/bin/poetry

Venv 路徑:

  • macOS: /Users/roy/Library/Caches/pypoetry/virtualenvs
poetry new poetry-demo
poetry add click
poetry add --group dev ruff
poetry add --group debug debugpy
poetry remove --group dev ruff

顯示 venv 的實際路徑:

poetry shell
poetry build

Operating modes

If you want to use Poetry only for dependency management but not for packaging, you can use the non-package mode:

[tool.poetry]
package-mode = false