Registry / data / mpi4py

mpi4py

JSON →
library4.1.2pypypi✓ verified 29d ago

mpi4py provides Python bindings for the Message Passing Interface (MPI) standard, enabling parallel programming with Python. It allows Python applications to leverage high-performance distributed memory architectures. The current version is 4.1.1, and it typically sees a few minor and patch releases per year, with major feature updates (like MPI standard support) in new minor versions.

pip install mpi4py
INSTALL
IMPORT
SIG · MPI4PY
M
mpi4py
datapythonv4.1.2
Install
1.6s avg
Import
—
Disk
20MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v4.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
build_error
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MPI
✓ from mpi4py import MPI
✗ import mpi4py.MPI

This 'Hello, World!' example demonstrates how to initialize MPI, get the rank of the current process, and the total number of processes in the communicator. Save it as `hello.py` and run with `mpirun -np 4 python hello.py` for 4 processes.

from mpi4py import MPI import os # Get the default communicator (all processes) comm = MPI.COMM_WORLD # Get the rank of the current process rank = comm.Get_rank() # Get the total number of processes size = comm.Get_size() # Each process prints its rank and size print(f"Hello from process {rank} of {size} on host {os.uname().nodename}") # Use a barrier to ensure all processes reach this point before exiting comm.Barrier()
Debug
Known issues
breakingPython 2.x support was dropped after mpi4py version 3.1.6. Versions 4.x and newer require Python 3.8+.
fix
Upgrade to Python 3.8 or newer to use mpi4py versions 4.0.0+.
affects: <=3.1.6 (last supporting Python 2)
breakingVersion 4.0.0 introduced support for the MPI-4.0 standard, including new features like sessions, persistent collectives, and partitioned communication. While mostly backward compatible, existing code might need updates to leverage new functionalities or if it relied on specific MPI-3 behaviors that changed in MPI-4.
fix
Consult the official mpi4py documentation and MPI-4.0 standard for details on new features and potential API changes if migrating from older MPI standards.
affects: 4.0.0+
gotchampi4py requires an underlying MPI implementation (e.g., Open MPI, MPICH, Intel MPI) to be installed on the system. It is a Python binding, not a standalone MPI library.
fix
Ensure a compatible MPI library (and its development headers if building from source) is installed on your system before installing and using mpi4py.
affects: All versions
gotchaMPI programs, including those written with mpi4py, must be executed using an MPI launcher like `mpirun` or `mpiexec`, not simply `python your_script.py`.
fix
Run your mpi4py script with `mpirun -np N python your_script.py`, replacing `N` with the desired number of processes.
affects: All versions
gotchaWhen installing mpi4py from source (e.g., if pre-built wheels are not available for your system/MPI configuration), you typically need MPI development headers installed (e.g., `libopenmpi-dev` or `mpich-dev` on Debian/Ubuntu, `openmpi-devel` or `mpich-devel` on CentOS/Fedora).
fix
Install the appropriate MPI development package for your system's MPI distribution.
affects: All versions (when building from source)
gotchaPre-built `mpi4py` wheels available on PyPI are built against specific MPI Application Binary Interfaces (ABIs), typically MPICH or Open MPI. If your system's MPI implementation is ABI-incompatible with the wheel, you may encounter runtime errors and will need to build `mpi4py` from source against your specific MPI library.
fix
Check `mpi4py` documentation for wheel ABI compatibility. If an incompatibility exists, build `mpi4py` from source (`pip install mpi4py --no-binary :all:`) after ensuring MPI development headers are present.
affects: 4.1.0+
Upgrade
Version history
4.1.2latest on PyPI · released May 16, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Resources
mpi4py — pip install mpi4py · libregistry