A pyenv-style Poetry version manager that helps you switch between different Poetry versions across multiple projects.
Inspired by python-poetry/poetry#4235 and the follow-up discussion #7866, where the community discussed the need for managing multiple Poetry versions. While asdf or pipx provide general solutions, poetryenv offers a dedicated pyenv-style workflow specifically for Poetry.
Use Case: If you only maintain one project, use the official Poetry installer. poetryenv is for managing multiple projects with different Poetry versions (e.g., legacy projects on 1.8.x, new projects on 2.x, or testing version upgrades).
curl -fsSL https://raw.githubusercontent.com/cdddg/poetryenv/main/install.sh | bashInstalls to
~/.localby default. Ensure~/.local/binis in yourPATH.
git clone https://github.com/cdddg/poetryenv.git ~/.poetryenv-src
cd ~/.poetryenv-src
PREFIX=$HOME/.local ./install.shAdd the following to your ~/.zshrc or ~/.bashrc:
eval "$(poetryenv init - zsh)" # for zsh
eval "$(poetryenv init - bash)" # for bashThen reload your shell:
exec $SHELL-
List available versions
poetryenv install --list
-
Install and set global version
poetryenv install 1.8.5 poetryenv global 1.8.5
-
Set project-specific version
cd /path/to/project poetryenv local 1.7.1
-
Verify current version
poetryenv version # Shows: 1.7.1 (set by .poetry-version)
| Command | Description |
|---|---|
poetryenv install <version>... |
Install one or more Poetry versions |
poetryenv install --list |
List available versions from PyPI |
poetryenv uninstall <version>... |
Remove one or more installed versions |
poetryenv global [version] |
Show or set global version |
poetryenv local [version] |
Show or set the project's .poetry-version |
poetryenv local --unset |
Remove project .poetry-version |
poetryenv version |
Show active version and source |
poetryenv versions |
List all installed versions |
poetryenv which |
Show path to active poetry executable |
poetryenv --version |
Show poetryenv version |
- The
.poetry-versionfile in a project directory overrides the global setting - Recommended to commit this file to version control (Git) to ensure team consistency
- Use
poetryenv local --unsetor delete the file to revert to global setting
-
Command not found
export PATH="$HOME/.local/bin:$PATH" eval "$(poetryenv init - zsh)"
-
Installation fails - Check dependencies
python3 --version # Requires Python 3.7+ curl --version -
Tab completion not working
exec $SHELL
Update poetryenv:
curl -fsSL https://raw.githubusercontent.com/cdddg/poetryenv/main/install.sh | bashRemove poetryenv:
rm -rf ~/.poetryenv ~/.local/bin/poetryenv ~/.local/bin/poetry ~/.local/share/poetryenv
# Then remove the 'poetryenv init' line from your shell startup fileEach Poetry version is completely isolated with separate config/data/cache directories:
~/.poetryenv/
├── global # Global version setting
└── versions/
├── 1.8.5/
│ ├── bin/poetry
│ ├── config/ # Version-specific config
│ ├── data/ # Version-specific data
│ └── cache/ # Version-specific cache
└── 2.0.1/
└── ...
When switching versions, these environment variables are automatically set:
POETRY_CONFIG_DIRPOETRY_DATA_DIRPOETRY_CACHE_DIR