Python beginner - No module named 'mpi4py'

I'm a student and I'm using python for the first time.

Currently I'm using Xubuntu 19.10 on a virtual machine, I checked the python and mpi4py installation.

My professor of "Parallel programming" gave me this simple python code.

from mpi4py import MPI
rank = comm.Get_rank()
print ("hello world from process ", rank)

I'm trying to run it but it doesn't works and I don't know how to fix it. When I try to execute, I receive this statement for each of the 4 process:

$ mpirun -n 4 python3
Traceback (most recent call last):
     File "", line 3, in <module>
     from mpi4py import MPI
ModuleNotFoundError: No module named 'mpi4py'


  • you can install mpi4py via pip in your terminal

    pip install mpi4py


     pip3 install mpi4py