skillfed

mpi4py

Python bindings for MPI

mpi4py v4.1.2 913.5K downloads/30d#4,739 on PyPI920
Permissive license BSD-3-Clause Active released

What it is and what it does

mpi4py is a mature Python interface to the MPI standard, allowing you to write distributed parallel programs that coordinate work across multiple processes and machines. It exposes MPI-2 C++ bindings through a Pythonic API, supporting both point-to-point communication (send/receive) and collective operations (broadcast, scatter, gather, reductions). The package handles any picklable Python object for general communication and offers optimized fast paths for objects that expose the Python buffer interface, such as NumPy arrays.

Beyond basic messaging, mpi4py provides process groups and topologies, parallel I/O, dynamic process management (spawn, accept/connect), and one-sided remote memory access operations. Installation is straightforward via pip when an MPI runtime is available; wheels support Linux, macOS, and Windows across multiple architectures and MPI implementations. The package is actively maintained, supports current Python versions (3.8 through 3.14), and has no known security vulnerabilities.

Use it for:

  • Distribute NumPy array computations across a cluster using collective operations for efficient data movement.
  • Implement parallel Monte Carlo simulations where independent processes run separate trials and gather results.
  • Coordinate long-running scientific workflows across HPC nodes with dynamic process spawning and name publishing.
  • Build fault-tolerant data processing pipelines using MPI's one-sided operations and passive target synchronization.
  • Parallelize embarrassingly parallel workloads (parameter sweeps, batch processing) across a supercomputer.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

mpi4py provides Python bindings for the Message Passing Interface (MPI) standard, enabling distributed and parallel computing across multiple processes and machines.

Yes, if you need distributed parallel computing in Python and have (or can install) an MPI runtime. mpi4py is mature, actively maintained, widely used in scientific computing, and carries no security vulnerabilities. Install friction is moderate—you must have an MPI implementation available—but wheels and clear documentation make setup straightforward on Linux, macOS, and Windows. Not necessary for single-machine parallelism (use multiprocessing or threading instead).

Install

mpi4py on PyPI

pip

pip install mpi4py

uv

uv add mpi4py

poetry

poetry add mpi4py

Installing mpi4py

Before you install

Medium install friction due to compiled C bindings requiring an MPI runtime (MPICH, Open MPI, Intel MPI, or Microsoft MPI) to be present on the system. Wheels are available for multiple platforms and Python versions, but successful installation depends on having a compatible MPI implementation already installed or available via package manager.

License in practice

BSD-3-Clause is a permissive license allowing commercial and private use with minimal restrictions, requiring only that the license text and copyright notice be included in distributions.

Quickstart

import mpi4py
from mpi4py import MPI

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
print(f'Rank {rank} of {size}')

An MPI implementation (MPICH, Open MPI, Intel MPI, or Microsoft MPI) must be installed and discoverable on your system; on Linux you may need to set LD_LIBRARY_PATH to locate the MPI shared library.

Verify before relying

  • Whether GPU-aware MPI features (CUDA/ROCm) are supported in the standard wheels or require custom builds
  • Performance characteristics and scalability limits for typical workloads
  • Compatibility matrix between specific MPI implementation versions and mpi4py releases

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.8)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 90 days since the last release
Last repo commit
First released
Downloads 913,486/month — #4,739 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mpi4py-4.1.2-cp310-abi3-macosx_10_9_x86_64.whl; mpi4py-4.1.2-cp310-abi3-macosx_11_0_arm64.whl; mpi4py-4.1.2-cp310-abi3-manylinux1_x86_64.manylinux_2_5_x86_64.whl; mpi4py-4.1.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; mpi4py-4.1.2-cp310-abi3-win_amd64.whl; mpi4py-4.1.2-cp310-cp310-macosx_10_9_x86_64.whl; mpi4py-4.1.2-cp310-cp310-macosx_11_0_arm64.whl; mpi4py-4.1.2-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl; mpi4py-4.1.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; mpi4py-4.1.2-cp310-cp310-win_amd64.whl; mpi4py-4.1.2-cp311-cp311-macosx_10_9_x86_64.whl; mpi4py-4.1.2-cp311-cp311-macosx_11_0_arm64.whl; mpi4py-4.1.2-cp311-cp311-manylinux1_x86_64.manylinux_2_5_x86_64.whl; mpi4py-4.1.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; mpi4py-4.1.2-cp311-cp311-win_amd64.whl; mpi4py-4.1.2-cp312-cp312-macosx_10_13_x86_64.whl; mpi4py-4.1.2-cp312-cp312-macosx_11_0_arm64.whl; mpi4py-4.1.2-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl; mpi4py-4.1.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; mpi4py-4.1.2-cp312-cp312-win_amd64.whl

Keywords: scientific computing, parallel computing, message passing interface, MPI

Development Status :: 6 - MatureEnvironment :: GPUEnvironment :: GPU :: NVIDIA CUDAIntended Audience :: DevelopersIntended Audience :: Science/ResearchOperating System :: MacOSOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: POSIX :: BSDOperating System :: POSIX :: LinuxOperating System :: UnixProgramming Language :: CProgramming Language :: CythonProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Scientific/EngineeringTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: Distributed ComputingTyping :: Typed

Tags

MPI Python bindingsdistributed parallel computingmessage passing interfacemulti-process communicationHPC Pythoncollective operations MPIpoint-to-point messaging
hpcdistributed-computingscientific-computing

More Scientific/Engineering packages