12

I want to install mpi4py. The installation fails with the error below. Please share the solution to the same error.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mpi4py
Failed to build mpi4py
ERROR: Could not build wheels for mpi4py, which is required to install pyproject.toml-based projects

[notice] A new release of pip available: 22.3 -> 22.3.1
[notice] To update, run: python -m pip install --upgrade pip

I installed pyproject-toml with "pip install pyproject-toml". But mpi4py still won't install. My python version is Python 3.8.0.

eve
  • 173
  • 1
  • 2
  • 9

5 Answers5

7

The following worked for me:

sudo apt update

sudo apt-get install libopenmpi-dev
2

It seems that related packages are twisted. Installed by following the steps below.

apt --fix-broken install
apt install mpich
pip install mpi4py
eve
  • 173
  • 1
  • 2
  • 9
2

I had the same error message. I used the Anaconda-Navigator interface and it worked fine.

Another option is to use brew. If OpenMPI isn't a dependency issue for you, the installation worked when I used it as well.

brew install mpi4py
Jas
  • 385
  • 7
  • 22
2
sudo apt-get install libopenmpi-dev

Doesn't work for me. In fact the openmpi lib is already the newest version on the server.
In fact, it turns out that conda works:

conda install mpi4py

Hope that you are also using conda.

Yikang Yue
  • 21
  • 3
-1

For me it worked when I used sudo before:

sudo pip install mpi4py
Fedor
  • 17,146
  • 13
  • 40
  • 131
  • Installation worked but python shows " no module named 'mpi4py' " – Dev Bhuyan Feb 15 '23 at 16:32
  • Yes, it will find no module named mpi4py. sudo will install it for the admin, not the active user. You would then have to run sudo's version of python as well, i.e. "sudo python <>.py" This is not a solution, do not do this. – user650261 Jun 01 '23 at 00:28