Reputation: 21
I want to run a mpi4py test file in terminal but it failed.
The operating system is mac and I am using anaconda2 with a python3. I installed mpi4py through anaconda environment. It works will on Pycharm, which also uses the anaconda environment.
The test code is:
from mpi4py import MPI
comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()
node_name = MPI.Get_processor_name() # get the name of the node
print ('Hello world from process %d at %s.' % (rank, node_name))
and I run this in terminal: mpirun -np 5 python test.py
the error message is :
Traceback (most recent call last): File "test.py", line 3, in from mpi4py import MPI ImportError: No module named mpi4py Traceback (most recent call last): File "test.py", line 3, in from mpi4py import MPI ImportError: No module named mpi4py Traceback (most recent call last): File "test.py", line 3, in from mpi4py import MPI ImportError: No module named mpi4py Traceback (most recent call last): File "test.py", line 3, in from mpi4py import MPI ImportError: No module named mpi4py Traceback (most recent call last): File "test.py", line 3, in from mpi4py import MPI
mpirun noticed that the job aborted, but has no info as to the process
Upvotes: 1
Views: 3142
Reputation: 63
Try python3
instead of python
in the command line.
mpirun -np 5 python3 test.py
Hope it works.
Upvotes: 3
Reputation: 21
figure it out...
Although I installed mpi4py through anaconda, and the default Python environment is python3.6 for anaconda, it did not installed mpi4py for the local environment.
After pip install mpi4py it works.
Still, I am a little confused why it works:( If someone happened to saw this post, please let me know the reason:)
Anyway... it is not that effective to use anaconda hehe.
Upvotes: 1