Error when installing mpi4py
Asked Answered
T

10

49

I'm trying to install mpi4py using pip install mpi4py, but I'm getting the following error:

error: Cannot find 'mpi.h' header. Check your configuration!!!

Earlier in the same error report I have,

clang: error: linker command failed with exit code 1 (use -v to see    invocation)

What might the problem be?

Thanks!

Tatianatatianas answered 10/2, 2015 at 20:8 Comment(2)
What commands do you execute? Do you have MPI installed?Ancilin
what is os x-specific about this?Brodeur
L
61

As the error says, there are libraries missing. I solved it by installing libopenmpi-dev package

sudo apt-get install libopenmpi-dev

and then installed the mpi4py using pip

pip install mpi4py
Loudmouth answered 25/1, 2017 at 22:35 Comment(3)
Note that this question was tagged osx and apt implies debian/ubuntu/related variants (but not saying this answer is bad)Armidaarmiger
Please don't do sudo pip install XXXBalkan
I am in a machine without sudo permissions. Yet I have conda. In that case, @9Dragons' answer solves it. conda install -c conda-forge mpi4py mpichFlint
F
41

I met with the similar problem and fixed this by firstly

brew install mpich

And then

pip install mpi4py
Fix answered 6/10, 2016 at 2:43 Comment(0)
K
13

you can do this:

brew install mpich

then

sudo find / -name mpicc

finally

env MPICC=/yourpath/mpicc pip3 install mpi4py
Karlmarxstadt answered 23/4, 2017 at 15:8 Comment(1)
The second step was not necessary in my case.Ingraft
B
12

None of the above solutions worked for me. I just use the conda install:

brew install mpich
conda install mpi4py

Baklava answered 10/5, 2020 at 22:8 Comment(0)
B
6

If mpi4py cannot find mpi.h, then likely the problem is how you are pointing mpi4py to your existing mpi library.

$ python setup.py build --mpicc=/where/you/have/mpicc

Now, there there are a few special cases related to OS X. You should consult http://mpi4py.scipy.org/docs/usrman/install.html to see if any apply to you.

Brodeur answered 23/4, 2015 at 15:16 Comment(1)
if you want to use pip, you can do: env MPICC=/path/to/mpicc/ pip install mpi4pyVadim
O
4

in my case, all solutions above is failed but succeded by conda

conda install -c conda-forge mpi4py mpich
Overcritical answered 7/11, 2022 at 5:32 Comment(0)
J
1

If somebody stumbles by and has the same problem I had:

I wanted to install mpi4py using pip as root:

sudo pip install mpi4py

I got the error message that mpi.h was missing during the installation. The path was set correctly, but only for my user, not for root. So if you run into trouble with missing libraries/headers during any installation, make sure the correct environment is also set up for root.

As I use mpi-selector to select which mpi implementation you use, I just had to run mpi-selector as root to set up everything correctly, and the installation succeeded.

Justicz answered 5/1, 2019 at 13:28 Comment(1)
mpi.h is a header file and LD_LIBRARY_PATH is for libraries. The issue was more likely with your $PATH (e.g. mpicc and friends were not in your default path)Toxoplasmosis
D
1

I have the similar issue, the following helps me as well.

sudo apt install libopenmpi-dev
Demulsify answered 1/11, 2021 at 6:11 Comment(0)
B
0

This might help on Fedora 38:

sudo dnf install python3-mpi4py-mpich python3-mpi4py-openmpi # second one not necessary I guess
module load mpi/mpich-$(arch)
pip3 install mpi4py

Mentioned here = https://mpi4py.readthedocs.io/en/latest/install.html2

Bluebell answered 9/1 at 15:38 Comment(0)
S
-4

first post here and new to python , sorry if im off topic.

i finally installed mpi4py

1) by downloading the right version from here https://www.lfd.uci.edu/~gohlke/pythonlibs/#mpi4py

2) open cmd ,change directory to where the downloaded file is

3) pip install some-package.whl ( How do I install a Python package with a .whl file? )

Subchloride answered 15/1, 2020 at 23:58 Comment(2)
Hi @Frikg, welcome to Stack Overflow. Indeed, your answer doesn't seem to be addressing the specific problem that the original poster had, and seems offtopic!Henceforward
hi @Henceforward , you are right . I 've been searching for days to install it so i hope that someone who has the same issue with me will come across with my answer (title helps to easy find this post) :)Subchloride

© 2022 - 2024 — McMap. All rights reserved.