error with mpi4py even if installed

Skip to first unread message

Luigi Marongiu

Apr 14, 2021, 9:36:09 AMApr 14
to mpi4py
I have installed mpi4py but when I try to use it, I get an error message:
$ conda activate tip_finder
(tip_finder) :~

(tip_finder) :~$  pip3 install mpi4py
Requirement already satisfied: mpi4py in ./src/conda/envs/tip_finder/lib/python3.7/site-packages (3.0.3)

(tip_finder) :~$ mpirun -np 12 ...
Traceback (most recent call last):
  File "/home/gigiux/src/TIP/", line 16, in <module>
    from mpi4py import MPI
ModuleNotFoundError: No module named 'mpi4py'
I even repeated by installing with conda system-wide; in the environment, mpi4py resulted installed (as expected) but I got the same error.
I am working with Ubuntu 20. 
What could be the problem? How can I solve it? 
Thank you

Lisandro Dalcin

Apr 14, 2021, 12:16:52 PMApr 14
My best guess is that your environment is broken. Looks like the python interpreter you are executing is not the right one. 
Please add the following two lines to the very beginning of your main script:

import sys

First launch it with only one mpi process (mpiexec -n 1 ...), and next two (mpiexec -n 2), and then jump to 12. 

What do you get?

You received this message because you are subscribed to the Google Groups "mpi4py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Lisandro Dalcin
Senior Research Scientist
Extreme Computing Research Center (ECRC)
King Abdullah University of Science and Technology (KAUST)
Reply all
Reply to author
0 new messages