# Build MediaPipe Python Wheel Package

<br />

This page describes how to build the MediaPipe Python wheel package from source
using Docker. You can use the built wheel package to install MediaPipe on a
local [Linux x86_64 machine](https://developers.google.com/edge/mediapipe/solutions/build_python.md.txt#manylinux).

> [!NOTE]
> **Note:** Prebuilt ARM64 Linux Python wheels (`manylinux_2_28_aarch64`) on PyPI work directly on Raspberry Pi 5 or newer running 64-bit Raspberry Pi OS (`glibc >= 2.28`), so you don't need to build a custom wheel from source for Raspberry Pi. Install the package with `python -m pip install mediapipe` by following the [Setup guide for Python](https://developers.google.com/edge/mediapipe/solutions/setup_python.md.txt).

## Prerequisites

To build the Python wheel package, your system requires the following:

- Docker with BuildKit support (Docker 18.09 or higher)

The Python build pipeline supports Python 3.9 or later (3.9--3.14).

## Invoke build using Docker

You can use the following Dockerfiles in the [MediaPipe
repository](https://github.com/google-ai-edge/mediapipe):

- [`Dockerfile.manylinux_2_28_x86_64`](https://github.com/google-ai-edge/mediapipe/blob/master/Dockerfile.manylinux_2_28_x86_64) builds `manylinux_2_28` wheels compatible with x86_64 Linux hosts.
- [`Dockerfile`](https://github.com/google-ai-edge/mediapipe/blob/master/Dockerfile) sets up the C++ MediaPipe framework build environment.

## Manylinux image for x86_64

Clone the [MediaPipe repository](https://github.com/google-ai-edge/mediapipe/)
and run the following commands from the repository root to build an x86_64
`manylinux_2_28` wheel. By default, `Dockerfile.manylinux_2_28_x86_64` builds
for Python 3.12 (`cp312-cp312`); if targeting another Python version, update
both `PYTHON_BIN` and the `auditwheel repair` path in the Dockerfile to match.

Build the Docker image:

```bash
DOCKER_BUILDKIT=1 docker build \
  -f Dockerfile.manylinux_2_28_x86_64 \
  -t mp_manylinux . \
  --build-arg "PYTHON_BIN=/opt/python/cp312-cp312/bin/python3.12"
```

Create a temporary container from the built image:

```bash
docker create -ti --name mp_pip_package_container mp_manylinux:latest
```

Copy the repaired `manylinux` wheel from `/wheelhouse` to your local machine:

```bash
docker cp mp_pip_package_container:/wheelhouse/. wheelhouse/
```

Remove the temporary Docker container:

```bash
docker rm -f mp_pip_package_container
```