# pex

> The PEX packaging toolchain.

- **URL**: https://www.freshcrate.ai/projects/pex
- **Author**: The PEX developers
- **Category**: Frameworks
- **Latest version**: `v2.96.0` (2026-06-01)
- **License**: Unknown
- **Source**: https://github.com/pex-tool/pex/blob/v2.92.3/CHANGES.md
- **Homepage**: https://github.com/pex-tool/pex
- **Language**: Python
- **GitHub**: 4,205 stars, 310 forks
- **Registry**: pypi (`pex`)
- **Tags**: `executable`, `freeze`, `lock`, `package`, `pypi`, `virtualenv`

## Description

***
PEX
***
.. image:: https://github.com/pex-tool/pex/actions/workflows/ci.yml/badge.svg?branch=main
   :target: https://github.com/pex-tool/pex/actions?query=branch%3Amain+workflow%3ACI

.. image:: https://img.shields.io/pypi/l/pex.svg
   :target: https://pypi.org/project/pex/

.. image:: https://img.shields.io/pypi/v/pex.svg
   :target: https://pypi.org/project/pex/

.. image:: https://img.shields.io/pypi/pyversions/pex.svg
   :target: https://pypi.org/project/pex/

.. image:: https://img.shields.io/pypi/wheel/pex.svg
   :target: https://pypi.org/project/pex/#files

.. image:: https://img.shields.io/discord/1205942638763573358
   :target: https://pex-tool.org/discord

.. contents:: **Contents**

Overview
========
pex is a library for generating .pex (Python EXecutable) files which are
executable Python environments in the spirit of `virtualenvs <https://virtualenv.pypa.io>`_.
pex is an expansion upon the ideas outlined in
`PEP 441 <https://peps.python.org/pep-0441/>`_
and makes the deployment of Python applications as simple as ``cp``.  pex files may even
include multiple platform-specific Python distributions, meaning that a single pex file
can be portable across Linux and OS X.

pex files can be built using the ``pex`` tool.  Build systems such as `Pants
<http://pantsbuild.org/>`_, `Buck <http://facebook.github.io/buck/>`_, and  `{py}gradle <https://github.com/linkedin/pygradle>`_  also
support building .pex files directly.

Still unsure about what pex does or how it works?  Watch this quick lightning
talk: `WTF is PEX? <https://www.youtube.com/watch?v=NmpnGhRwsu0>`_.

pex is licensed under the Apache2 license.


Installation
============

To install pex, simply

.. code-block:: bash

    $ pip install pex

You can also build pex in a git clone using uv:

.. code-block:: bash

    $ uv run dev-cmd package
    $ cp dist/pex ~/bin

This builds a pex binary in ``dist/pex`` that can be copied onto your ``$PATH``.
The advantage to this approach is that it keeps your Python environment as empty as
possible and is more in-line with what pex does philosophically.


Simple Examples
===============

Launch an interpreter with ``requests``, ``flask`` and ``psutil`` in the environment:

.. code-block:: bash

    $ pex requests flask 'psutil>2,<3'

Save Dependencies From Pip
~~~~~~~~~~~~~~~~~~~~~~~~~~

Or instead freeze your current virtualenv via requirements.txt and execute it anywhere:

.. code-block:: bash

    $ pex $(pip freeze) -o my_virtualenv.pex
    $ deactivate
    $ ./my_virtualenv.pex

Ephemeral Environments
~~~~~~~~~~~~~~~~~~~~~~

Run webserver.py in an environment containing ``flask`` as a quick way to experiment:

.. code-block:: bash

    $ pex flask -- webserver.py

Launch Sphinx in an ephemeral pex environment using the Sphinx entry point ``sphinx:main``:

.. code-block:: bash

    $ pex sphinx -e sphinx:main -- --help

Using Entry Points
~~~~~~~~~~~~~~~~~~

Projects specifying a ``console_scripts`` entry point in their configuration
can build standalone executables for those entry points.

To build a standalone ``pex-tools-executable.pex`` binary that runs the
``pex-tools`` console script found in all pex version ``2.1.35`` and newer distributions:

.. code-block:: bash

    $ pex "pex>=2.1.35" --console-script pex-tools --output-file pex-tools-executable.pex

Specifying A Specific Interpreter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can also build pex files that use a specific interpreter type:

.. code-block:: bash

    $ pex "pex>=2.1.35" -c pex-tools --python=pypy -o pex-tools-pypy-executable.pex

Most pex options compose well with one another, so the above commands can be
mixed and matched, and equivalent short options are available.

For a full list of options, just type ``pex --help``.


Documentation
=============

More documentation about Pex, building .pex files, and how .pex files work
is available at https://docs.pex-tool.org.


Development
===========

Pex uses `uv <https://docs.astral.sh/uv/>`_ with `dev-cmd <https://pypi.org/project/dev-cmd/>`_ for
test and development automation. After you have installed `uv`, to run the Pex test suite, just
run `dev-cmd` via `uv`:

.. code-block:: bash

    $ uv run dev-cmd

The `dev-cmd` command runner provides many useful options, explained at
https://pypi.org/project/dev-cmd/ . Below, we provide some of the most commonly used commands when
working on Pex, but the docs are worth acquainting yourself with to better understand how `dev-cmd`
works and how to execute more advanced work flows.

To run a specific command, identify the name of the command you'd like to invoke by running
``uv run dev-cmd --list``, then invoke the command by name like this:

.. code-block::

    $ uv run dev-cmd format

That's a fair bit of typing. An shell alias is recommended, and the standard is `uvrc` which I'll
use from here on out.

To run MyPy:

.. code-block::

    $ uvrc typecheck

All of our tests allow passthrough arguments to `pytest`, which can be helpful to

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `v2.96.0` | 2026-06-01 | High | ---  ## 2.96.0  This release adds support for `--pip-version 26.1.2`.  * Add support for `--pip-version 26.1.2`. (#3182) *** \|file\|sha256\|size\| \|----\|------\|----\| \|pex\|7d51fc3c979f94ff4898f4d3ef8405b34a5988ffbee6ec4627946cfda154e0fc\|5125572\| \|pex-linux-aarch64\|a16e70e5665c52fb11f7ca670b7d0c7acc2a707654ea1b8f4cce5fe2ed527aa4\|36882357\| \|pex-linux-armv7l\|4b32672139e1cce973492adb58452a3c62c752d1e85dd4c2afa1e963b1adfb08\|33265856\| \|pex-linux-riscv64\|01055141e7b96f497fb4e24f5a9f4a24f341c098dbae7ea84153 |
| `v2.95.3` | 2026-05-24 | High | ---  ## 2.95.3  This release has `--venv` PEXes using PEP-829 `.start` files to affect `PEX_EXTRA_SYS_PATH` `sys.path` mutation instead of `.pth` import lines. Although the `.pth` file is still emitted for maximum compatibility with third party code, the `PEX_EXTRA_SYS_PATH.pth` file will no longer be emitted for PEX venvs using Python 3.20 and greater. See [PEP-829](https://peps.python.org/pep-0829) and the [3.15 notes](https://docs.python.org/3.15/whatsnew/3.15.html#whatsnew315-startup-files). |
| `v2.95.1` | 2026-05-16 | High | ---  ## 2.95.1  This release fixes a bug in the `--venv-repository` resolver that ignored extras when determining if a requirement had already been resolved.  * Fix `--venv-repository` resolver extras handling. (#3176) *** \|file\|sha256\|size\| \|----\|------\|----\| \|pex\|2cc018cf1a112ae7f94e78456f90da2d15c1a3c1327da4c73c98701ab1f8f732\|5124990\| \|pex-linux-aarch64\|ebc9945c0b2e920023233f192922963cbe0fe5ea08284b4f71a4e0e61724e4dc\|36881764\| \|pex-linux-armv7l\|1683627f4aab0ff0dbf603f6cc9186554611e2897ed739b9 |
| `v2.95.0` | 2026-05-09 | High | ---  ## 2.95.0  Add initial opt-in support for the native PEX runtime provided by [`pexrc`](https://github.com/pex-tool/pex.rc) via the `--rc` flag.  * Introduce the `--rc` flag to opt in to a native PEX runtime. (#3171) *** \|file\|sha256\|size\| \|----\|------\|----\| \|pex\|51ec878f1deb129a2cc728f5d473743228f82d9fb3053ca49a45331cfdf5d1e6\|5123805\| \|pex-linux-aarch64\|8fd5c05a62010cf574d4be501b6c3683295a1b2d2f5bb69e12a5d0e1246945e9\|36880586\| \|pex-linux-armv7l\|f46c852a707a4a455a7dff0394c28d41752a48a6b28b11 |
| `v2.94.0` | 2026-05-05 | High | ---  ## 2.94.0  This release adds support for `--pip-version 26.1.1`.  * Add support for `--pip-version 26.1.1`. (#3168) *** \|file\|sha256\|size\| \|----\|------\|----\| \|pex\|3a6950a6241ba06a9e3b30a4fcf46d9f3fb5a66ca3edd7370e1a1d6f5df56d8c\|5117266\| \|pex-linux-aarch64\|d71ba7591010a5845750804eff2835b7395d7dc24e0ecc470144efefc6755e31\|36874038\| \|pex-linux-armv7l\|0fc39fb47066e28829cda04497cd8976d1791223706507e0bb4a652213438b78\|33257541\| \|pex-linux-riscv64\|6123f006c4b54048b8299efd1b82b9b61df253160c276635b0dc |
| `v2.93.4` | 2026-05-01 | High | ---  ## 2.93.4  This release is a follow-on to #3164 that fixes the other spot in the code base susceptible to hashlib `guaranteed_algorithms` not being available.  * Ensure hash algorithms are available for PEP-691 lookups. (#3166) *** \|file\|sha256\|size\| \|----\|------\|----\| \|pex\|e6325b06000c35f57e8ffb3f62f713f79f92a817c091748c9c48e297a24b37e2\|5117262\| \|pex-linux-aarch64\|75bb80e3728d6a1c8255f107195b284e15fce1c622ef9acbd43fca43e3426962\|36874029\| \|pex-linux-armv7l\|98f46f370ad198487e0f429a040c4647e2 |
| `v2.93.0` | 2026-04-27 | High | ---  ## 2.93.0  This release adds support for `--pip-version 26.1`.  * Add support for `--pip-version 26.1`. (#3155) *** \|file\|sha256\|size\| \|----\|------\|----\| \|pex\|6f8b9f52c1a96e51345c0a60317165837d07309dce357ecb11d54e9c36d974e3\|5134461\| \|pex-linux-aarch64\|370753534bac7926f5bc3959ec709fdf62e91cc6ceaf3e5689621e8abafec26b\|36891236\| \|pex-linux-armv7l\|deeca346cad896806f21cbcfadecf34ebc3039158d9126a718da03d9df3baab2\|33274742\| \|pex-linux-riscv64\|8b3e192ad98d70706ef2f9057dc6e536d489201d7c0459beedb03fb5 |
| `2.92.3` | 2026-04-21 | Low | Imported from PyPI (2.92.3) |
| `v2.92.3` | 2026-04-15 | High | ---  ## 2.92.3  This release fixes universal lock splits that use extra markers not directly related to `--style universal` target systems or `--interpreter-constraints`. Previously these triggered an internal exception. That bug is now fixed and the scope of manually induced splits is now broadened to include extra markers when used alone.  * Fix universal lock splitting for extra markers. (#3150) *** \|file\|sha256\|size\| \|----\|------\|----\| \|pex\|925d08cc9ffe5cff5a3dd67519e24bdb42b1257814bcae7355b |
| `v2.92.3` | 2026-04-15 | Medium | ---  ## 2.92.3  This release fixes universal lock splits that use extra markers not directly related to `--style universal` target systems or `--interpreter-constraints`. Previously these triggered an internal exception. That bug is now fixed and the scope of manually induced splits is now broadened to include extra markers when used alone.  * Fix universal lock splitting for extra markers. (#3150) *** \|file\|sha256\|size\| \|----\|------\|----\| \|pex\|925d08cc9ffe5cff5a3dd67519e24bdb42b1257814bcae7355b |

## Citation

- HTML: https://www.freshcrate.ai/projects/pex
- Markdown: https://www.freshcrate.ai/projects/pex.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/pex/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
