Pipx, the brew for python based Applications 🍻🐍
Tags: python, productivity
Published: 2020-08-31 20:09:29

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...

[`pipx` comes to the rescue!](https://pipxproject.github.io/pipx/)

## 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**](https://pipxproject.github.io/pipx/#overview-what-is-pipx)

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](https://www.ansible.com/) via pipx simply run:

```bash
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!](https://pipxproject.github.io/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](https://pipxproject.github.io/pipx/#overview-what-is-pipx)
- [Python Bytes Podcast - Episode #118: Better Python executable management with pipx ](https://pythonbytes.fm/episodes/show/118/better-python-executable-management-with-pipx)
- [pipx in comparison to other/similar tools](https://pipxproject.github.io/pipx/comparisons/)
- [Pipx, the brew for python based Applications](https://blog.keyboardinterrupt.com/use-pipx-for-installing-python-software/)

> Cover Art Image by [@worldspectrum](https://www.pexels.com/photo/beige-python-on-brown-branch-of-tree-1108192/)