'Problem with mpi4py-all ranks become root

I have a problem when running a simple python script with mpi4py. The script reads,

\#!/usr/bin/env python

import mpi4py.MPI as MPI

comm = MPI.COMM_WORLD

size = comm.Get_size()

rank = comm.Get_rank()

node_name = MPI.Get_processor_name()

print (rank)

It worked normally in my platform (Ubuntu) before. But today when I run it for test, no matter how many cores I invoke, all ranks print "0".

I have no idea what could be the cause? Can anyone help me? Thanks!

I expect all ranks print their rank number But all of them print "0" instead



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source