When getting into python, one can easily mess up their python environment, by mixing different methods of installing Python based applications, packages, libraries and dependencies.
A common mistake is installing Python Packages both via your Linux distributions package manager e.G. apt-get
or yum
and via pip
possibly mixed with some sudo pip
Here and there.
This way you are likely to mess up your Python environment with conflicting dependencies, and it is easy to loose track which Part of your Installation comes from what source...
So, what does pipx do?
pipx is a tool to help you install and run end-user applications written in Python. It's roughly similar to macOS's brew, JavaScript's npx, and Linux's apt.
It's closely related to pip. In fact, it uses pip, but is focused on installing and managing Python packages that can be run from the command line directly as applications. source
Pipx provides easy installation and isolation of any python application that you can run from the commandline i.E. the python-openstack
client, ansible
, salt
, cookiecutter
, black
and many more.
Whilst those and other python application might interfere with each other, when mangled together in one environment.
When installing them via pipx Each application is automatically and individually, isolated into their own virtual Environment! 🎉
In Example, To install Ansible via pipx simply run:
pipx install ansible
And viola ✨, pipx will create a virtual environment for ansible, install it, and, add all the commandline tools provided by ansible
to your $PATH
variable!
# pipx list
venvs are in /home/keyboardinterrupt/.local/pipx/venvs
apps are exposed on your $PATH at /home/cstein/.local/bin
package ansible 2.9.10, Python 3.6.9
- ansible
- ansible-config
- ansible-connection
- ansible-console
- ansible-doc
- ansible-galaxy
- ansible-inventory
- ansible-playbook
- ansible-pull
- ansible-test
- ansible-vault
I usually use pipx for installation of python based applications and only ever use virtual environments and pip directly whenever I am developing.
I highly recommend checking out pipx! It is a great tool to keep your python based tools neatly organized, ready to use, and easy to upgrade.
I ❤ pipx
Links and Resources
- pipx
- Python Bytes Podcast - Episode #118: Better Python executable management with pipx
- pipx in comparison to other/similar tools
- Pipx, the brew for python based Applications
Cover Art Image by @worldspectrum
Top comments (0)