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
Try python3
instead of python
in the command line.
mpirun -np 5 python3 test.py
Hope it works.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.