• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H05-Aug-2021-4,7593,812

LICENSEH A D05-Aug-20211.1 KiB2217

MANIFEST.inH A D05-Aug-2021353 1511

PKG-INFOH A D05-Aug-202111.7 KiB301210

README.mdH A D05-Aug-202110.7 KiB274186

pyproject.tomlH A D05-Aug-2021324 1612

setup.cfgH A D05-Aug-20211.3 KiB5145

setup.pyH A D05-Aug-2021273 159

README.md

1<p align="center">
2<a href="https://pypa.github.io/pipx/">
3<img align="center" src="https://github.com/pypa/pipx/raw/master/logo.png"/>
4</a>
5</p>
6
7# pipx — Install and Run Python Applications in Isolated Environments
8
9<p align="center">
10<a href="https://github.com/pypa/pipx/raw/master/pipx_demo.gif">
11<img src="https://github.com/pypa/pipx/raw/master/pipx_demo.gif"/>
12</a>
13</p>
14
15<p align="center">
16<a href="https://github.com/pypa/pipx/actions?query=workflow%3ATest"><img src="https://github.com/pypa/pipx/workflows/Test/badge.svg?branch=master" alt="Test CI" ></a>
17<a href="https://badge.fury.io/py/pipx"><img src="https://badge.fury.io/py/pipx.svg" alt="PyPI version"></a>
18</p>
19
20**Documentation**: https://pypa.github.io/pipx/
21
22**Source Code**: https://github.com/pypa/pipx
23
24_For comparison to other tools including pipsi, see [Comparison to Other Tools](https://pypa.github.io/pipx/comparisons/)._
25
26## Install pipx
27
28On macOS:
29
30```
31brew install pipx
32pipx ensurepath
33```
34
35Upgrade pipx with `brew update && brew upgrade pipx`.
36
37Otherwise, install via pip (requires pip 19.0 or later):
38
39```
40python3 -m pip install --user pipx
41python3 -m pipx ensurepath
42```
43
44Upgrade pipx with `python3 -m pip install --user -U pipx`.
45
46Shell completions are available by following the instructions printed with this command:
47```
48pipx completions
49```
50
51For more details, see the [installation instructions](https://pypa.github.io/pipx/installation/).
52
53
54## Overview: What is `pipx`?
55
56pipx 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](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b), and Linux's `apt`.
57
58It'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.
59
60### How is it Different from pip?
61
62pip is a general-purpose package installer for both libraries and apps with no environment isolation. pipx is made specifically for application installation, as it adds isolation yet still makes the apps available in your shell: pipx creates an isolated environment for each application and its associated packages.
63
64pipx does not ship with pip, but installing it is often an important part of bootstrapping your system.
65
66
67### Where Does `pipx` Install Apps From?
68By default, pipx uses the same package index as pip, [PyPI](https://pypi.org/). pipx can also install from all other sources pip can, such as a local directory, wheel, git url, etc.
69
70Python and PyPI allow developers to distribute code with "console script entry points". These entry points let users call into Python code from the command line, effectively acting like standalone applications.
71
72pipx is a tool to install and run any of these thousands of application-containing packages in a safe, convenient, and reliable way. **In a way, it turns Python Package Index (PyPI) into a big app store for Python applications.** Not all Python packages have entry points, but many do.
73
74If you would like to make your package compatible with pipx, all you need to do is add a [console scripts](https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-console-scripts-entry-point) entry point. If you're a poetry user, use [these instructions](https://python-poetry.org/docs/pyproject/#scripts).
75
76
77## Features
78`pipx` enables you to
79
80- Expose CLI entrypoints of packages ("apps") installed to isolated environments with the `install` command. This guarantees no dependency conflicts and clean uninstalls!
81- Easily list, upgrade, and uninstall packages that were installed with pipx
82- Run the latest version of a Python application in a temporary environment with the `run` command
83
84Best of all, pipx runs with regular user permissions, never calling `sudo pip install` (you aren't doing that, are you? ��).
85
86
87### Walkthrough: Installing a Package and its Applications With `pipx`
88
89You can globally install an application by running
90
91```
92pipx install PACKAGE
93```
94
95This automatically creates a virtual environment, installs the package, and adds the package's associated applications (entry points) to a location on your `PATH`. For example, `pipx install pycowsay` makes the `pycowsay` command available globally, but sandboxes the pycowsay package in its own virtual environment. **pipx never needs to run as sudo to do this.**
96
97Example:
98
99```
100>> pipx install pycowsay
101  installed package pycowsay 2.0.3, Python 3.7.3
102  These apps are now globally available
103    - pycowsay
104done! ✨ �� ✨
105
106
107>> pipx list
108venvs are in /home/user/.local/pipx/venvs
109apps are exposed on your $PATH at /home/user/.local/bin
110   package pycowsay 2.0.3, Python 3.7.3
111    - pycowsay
112
113
114# Now you can run pycowsay from anywhere
115>> pycowsay mooo
116  ____
117< mooo >
118  ====
119         \
120          \
121            ^__^
122            (oo)\_______
123            (__)\       )\/\
124                ||----w |
125                ||     ||
126
127```
128
129### Installing from Source Control
130
131You can also install from a git repository. Here, `black` is used as an example.
132```
133pipx install git+https://github.com/psf/black.git
134pipx install git+https://github.com/psf/black.git@branch  # branch of your choice
135pipx install git+https://github.com/psf/black.git@ce14fa8b497bae2b50ec48b3bd7022573a59cdb1  # git hash
136pipx install https://github.com/psf/black/archive/18.9b0.zip  # install a release
137```
138
139### Walkthrough: Running an Application in a Temporary Virtual Environment
140
141This is an alternative to `pipx install`.
142
143`pipx run` downloads and runs the above mentioned Python "apps" in a one-time, temporary environment, leaving your system untouched afterwards.
144
145This can be handy when you need to run the latest version of an app, but don't necessarily want it installed on your computer.
146
147You may want to do this when you are initializing a new project and want to set up the right directory structure, when you want to view the help text of an application, or if you simply want to run an app in a one-off case and leave your system untouched afterwards.
148
149For example, the blog post [How to set up a perfect Python project](https://sourcery.ai/blog/python-best-practices/) uses `pipx run` to kickstart a new project with [cookiecutter](https://github.com/cookiecutter/cookiecutter), a tool that creates projects from project templates.
150
151A nice side benefit is that you don't have to remember to upgrade the app since `pipx run` will automatically run a recent version for you.
152
153Okay, let's see what this looks like in practice!
154
155```
156pipx run APP [ARGS...]
157```
158
159This will install the package in an isolated, temporary directory and invoke the app. Give it a try:
160
161```
162> pipx run pycowsay moo
163
164  ---
165< moo >
166  ---
167   \   ^__^
168    \  (oo)\_______
169       (__)\       )\/\
170           ||----w |
171           ||     ||
172
173
174```
175
176Notice that you **don't need to execute any install commands to run the app**.
177
178Any arguments after the application name will be passed directly to the application:
179
180```
181> pipx run pycowsay these arguments are all passed to pycowsay!
182
183  -------------------------------------------
184< these arguments are all passed to pycowsay! >
185  -------------------------------------------
186   \   ^__^
187    \  (oo)\_______
188       (__)\       )\/\
189           ||----w |
190           ||     ||
191
192```
193
194Re-running the same app is quick because pipx caches Virtual Environments on a per-app basis. The caches only last a few days, and when they expire, pipx will again use the latest version of the package. This way you can be sure you're always running a new version of the package without having to manually upgrade.
195
196If the app name does not match that package name, you can use the `--spec` argument:
197```
198pipx run --spec PACKAGE APP
199```
200
201You can also use the `--spec` argument to run a specific version, or use any other `pip`-specifier:
202```
203pipx run --spec PACKAGE==1.0.0 APP
204```
205
206### Running from Source Control
207
208You can also run from a git repository. Here, `black` is used as an example.
209```
210pipx run --spec git+https://github.com/psf/black.git black
211pipx run --spec git+https://github.com/psf/black.git@branch black  # branch of your choice
212pipx run --spec git+https://github.com/psf/black.git@ce14fa8b497bae2b50ec48b3bd7022573a59cdb1 black  # git hash
213pipx run --spec https://github.com/psf/black/archive/18.9b0.zip black # install a release
214```
215
216### Running from URL
217
218You can run .py files directly, too.
219
220```
221pipx run https://gist.githubusercontent.com/cs01/fa721a17a326e551ede048c5088f9e0f/raw/6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py
222pipx is working!
223```
224
225### Summary
226That's it! Those are the most important commands `pipx` offers. To see all of pipx's documentation, run `pipx --help` or see the [docs](https://pypa.github.io/pipx/docs/).
227
228## Testimonials
229
230<div>
231"Thanks for improving the workflow that pipsi has covered in the past. Nicely done!"
232<div style="text-align: right; margin-right: 10%; font-style:italic;">
233—<a href="https://twitter.com/jezdez">Jannis Leidel</a>, PSF fellow, former pip and Django core developer, and founder of the Python Packaging Authority (PyPA)
234</div>
235</div>
236
237<p></p>
238
239<div>
240"My setup pieces together pyenv, poetry, and pipx. [...] For the things I need, it’s perfect."
241<div style="text-align: right; margin-right: 10%; font-style:italic;">
242—<a href="https://twitter.com/jacobian">Jacob Kaplan-Moss</a>, co-creator of Django in blog post <a href="https://jacobian.org/2019/nov/11/python-environment-2020/">My Python Development Environment, 2020 Edition</a>
243</div>
244</div>
245
246<p></p>
247
248<div>
249"I'm a big fan of pipx. I think pipx is super cool."
250<div style="text-align: right; margin-right: 10%; font-style:italic;">
251—<a href="https://twitter.com/mkennedy">Michael Kennedy</a>, co-host of PythonBytes podcast in <a href="https://pythonbytes.fm/episodes/transcript/139/f-yes-for-the-f-strings">episode 139</a>
252</div>
253</div>
254
255<p></p>
256
257
258
259## Credits
260
261pipx was inspired by [pipsi](https://github.com/mitsuhiko/pipsi) and [npx](https://github.com/npm/npx). It was created by [Chad Smith](https://github.com/cs01/) and has had lots of help from [contributors](https://github.com/pypa/pipx/graphs/contributors). The logo was created by [@IrishMorales](https://github.com/IrishMorales).
262
263pipx is maintained by a team of volunteers (in alphabetical order)
264
265- [Bernát Gábor](https://github.com/gaborbernat)
266- [Chad Smith](https://github.com/cs01) - co-lead maintainer
267- [Matthew Clapp](https://github.com/itsayellow) - co-lead maintainer
268- [Tzu-ping Chung](https://github.com/uranusjr)
269
270## Contributing
271Issues and Pull Requests are definitely welcome! Check out [Contributing](https://pypa.github.io/pipx/contributing/) to get started.
272Everyone who interacts with the pipx project via codebase, issue tracker, chat rooms, or otherwise is expected to follow
273the [PSF Code of Conduct](https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md).
274