35

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!

nargles324
  • 383
  • 1
  • 3
  • 8

7 Answers7

33

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

sudo apt install libopenmpi-dev

and then installed the mpi4py using pip

sudo pip install mpi4py
mcshell
  • 447
  • 4
  • 4
32

I met with the similar problem and fixed this by firstly

brew install mpich

And then

pip install mpi4py
American curl
  • 1,029
  • 1
  • 14
  • 20
5

you can do this:

brew install mpich

then

sudo find / -name mpicc

finally

env MPICC=/yourpath/mpicc pip3 install mpi4py
demonchang
  • 51
  • 1
  • 1
4

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.

Rob Latham
  • 4,734
  • 2
  • 21
  • 42
2

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

brew install mpich
conda install mpi4py

0

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.

Community
  • 1
  • 1
thepith
  • 47
  • 6
  • `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) – Gilles Gouaillardet Jan 06 '19 at 06:25
-2

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? )

frikg
  • 1
  • 1
    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! – frandroid Jan 16 '20 at 00:35
  • hi @frandroid , 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) :) – frikg Jan 16 '20 at 01:51