Last modified: May 26, 2025 By Alexander Williams
Install Python Packages with pipx
pipx is a tool for installing Python applications in isolated environments. It helps avoid conflicts between dependencies. This guide will show you how to use it.
Table Of Contents
What is pipx?
pipx installs Python packages in separate environments. This keeps your system clean. It's perfect for CLI tools and applications.
Unlike pip
, pipx creates isolated environments for each package. This prevents dependency conflicts.
Install pipx
First, ensure you have Python installed. For help, see Install Python on Ubuntu in 5 Steps.
Install pipx with pip:
python -m pip install --user pipx
python -m pipx ensurepath
This installs pipx and adds it to your PATH.
Basic pipx Commands
Here are the essential pipx commands you'll use:
Install a Package
Use pipx install
to add a package:
pipx install package-name
For example, install the popular black formatter:
pipx install black
Run a Package Once
Use pipx run
to run a package without installing it:
pipx run package-name
This is great for one-time use tools.
List Installed Packages
See all packages installed with pipx:
pipx list
Uninstall a Package
Remove a package with:
pipx uninstall package-name
Advanced pipx Usage
pipx has more powerful features for advanced users.
Install from GitHub
You can install packages directly from GitHub. Learn more in Install Python Packages from GitHub.
pipx install git+https://github.com/user/repo.git
Specify Python Version
Use a specific Python version with:
pipx install --python python3.9 package-name
Inspect Environments
See where packages are installed:
pipx list --verbose
Example: Installing Poetry with pipx
Let's install the Poetry package manager as an example.
pipx install poetry
Verify it works:
poetry --version
Output:
Poetry version 1.1.7
When to Use pipx vs pip
Use pipx for:
- Applications you run from command line
- Tools with many dependencies
- Packages that might conflict
Use pip for:
- Libraries in your projects
- Development dependencies
Troubleshooting pipx
If you have issues, try these solutions.
Command Not Found
If pipx commands aren't found, ensure your PATH is set correctly. See Install Python on macOS with Homebrew for PATH setup help.
Permission Errors
Use the --user
flag if you get permission errors:
python -m pip install --user pipx
Conclusion
pipx is a powerful tool for managing Python applications. It keeps your system clean and avoids conflicts. Start using it today for your Python tools.
Remember to use pipx for applications and pip for libraries. This simple rule will save you many headaches.