Poetry Command Not Found: Complete Installation and Fix Guide
When you encounter the poetry: command not found
error, it's typically because Poetry isn't properly added to your system's PATH environment variable. This comprehensive guide covers solutions for Windows, macOS, and Linux/WSL environments.
Understanding the Problem
Poetry is a Python dependency management tool that needs to be accessible from your command line. The error occurs when:
- Poetry is installed but not in your system PATH
- Shell configuration files aren't properly configured
- Installation was incomplete or corrupted
- System restarts cleared temporary PATH additions
Recommended Installation Methods
Official Installation (All Platforms)
The Poetry team recommends using their official installer:
curl -sSL https://install.python-poetry.org | python3 -
After installation, the output will show the exact path where Poetry was installed and instructions for adding it to your PATH.
Using pipx (Recommended)
pipx isolates Python applications and automatically handles PATH configuration:
# Install pipx first if needed
python3 -m pip install --user pipx
python3 -m pipx ensurepath
# Install Poetry with pipx
pipx install poetry
Platform-Specific Installers
brew install poetry
choco install poetry
sudo apt update
sudo apt install python3-poetry
PATH Configuration Solutions
For macOS and Linux/WSL Users
Most Unix-like systems install Poetry to ~/.local/bin
. Add this to your shell configuration:
Find your shell type:
bashecho $SHELL
Edit the appropriate configuration file:
bashecho 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc source ~/.zshrc
bashecho 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc
bashecho 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc
WARNING
If your shell configuration file doesn't exist, create it first:
touch ~/.zshrc # or ~/.bashrc
For Windows Users
Windows typically installs Poetry to one of these locations:
%USERPROFILE%\AppData\Roaming\pypoetry\venv\Scripts
%APPDATA%\Python\Scripts
%USERPROFILE%\.local\bin
Using PowerShell:
# Add to PATH temporarily
$env:Path += ";$env:USERPROFILE\AppData\Roaming\pypoetry\venv\Scripts"
# Add to PATH permanently
[Environment]::SetEnvironmentVariable("Path",
"$env:Path;$env:USERPROFILE\AppData\Roaming\pypoetry\venv\Scripts",
[EnvironmentVariableTarget]::User)
Using System Properties:
- Press Win + R, type
sysdm.cpl
, and press Enter - Click "Environment Variables"
- Under "User variables", select "Path" and click "Edit"
- Click "New" and add the Poetry installation path
- Click OK to save changes
Verification and Testing
After configuration, verify Poetry is accessible:
poetry --version
You should see output similar to:
Poetry (version 1.8.2)
Troubleshooting Common Issues
Installation Appears Successful but Command Not Found
This indicates a PATH configuration issue. Check where Poetry was installed:
# Unix systems
find ~ -name "poetry" -type f -executable 2>/dev/null
# Windows PowerShell
Get-ChildItem -Path $env:USERPROFILE -Recurse -Filter "poetry*" -File | Where-Object {$_.Name -eq "poetry.exe"}
Add the discovered path to your system PATH using the methods above.
Shell Plugin Requirement (Poetry 2.0+)
For Poetry versions 2.0 and later, you may need the shell plugin:
poetry self add poetry-plugin-shell
Reinstalling Poetry
If configuration seems correct but Poetry still isn't working, try reinstalling:
# Uninstall first
pip uninstall poetry
# Reinstall using recommended method
curl -sSL https://install.python-poetry.org | python3 -
Platform-Specific Notes
Windows with WSL
When using Poetry in WSL (Windows Subsystem for Linux):
- Install Poetry within your WSL distribution, not Windows
- Use the Linux installation methods above
- Ensure you're editing WSL configuration files, not Windows ones
macOS Specifics
Recent macOS versions use zsh as the default shell. Ensure you're modifying ~/.zshrc
rather than ~/.bash_profile
or ~/.bashrc
.
Best Practices
- Use pipx for isolation: pipx keeps Poetry and its dependencies separate from your system Python
- Verify installation: Always run
poetry --version
after installation - Keep updated: Regularly update Poetry with
poetry self update
- Check documentation: Refer to official Poetry documentation for latest instructions
INFO
The deprecated get-poetry.py
installer mentioned in some older solutions should no longer be used. Always use the current official installation method.
By following these guidelines, you should be able to resolve the "poetry: command not found" error and maintain a stable Poetry installation across system restarts.