Using mpi4py with python3

1,404 views
Skip to first unread message

shine....@gmail.com

unread,
Sep 26, 2014, 7:50:52 AM9/26/14
to mpi...@googlegroups.com
Hello Guys

I am new to mpi4py. I have a program with is made for python3. I want to parallelize some parts of it so I am using mpi4py. I managed to run some examples as given in the scipy website (http://mpi4py.scipy.org/docs/usrman/tutorial.html). They work good. But when I run the scripts with command

"mpiexec -n 3 python3 myMpi4pyScript.py"
if I put python instead of python3 it works fine but I think then the python used is python2.7 but not python3. Because I need to run my scripts with python3 I use python3 in above command.

it gives me an error saying there is no module named mpi4py to import MPI. Any help .. ? How is it possible to run python program parallelized with mpi4py with python3.

Setup:
Ubuntu 14.04 LTS
OpenMPI 1.5
mpi4py installed using pip.

Thanks in advance

Lisandro Dalcin

unread,
Sep 26, 2014, 2:48:05 PM9/26/14
to mpi4py
On 26 September 2014 14:50, <shine....@gmail.com> wrote:
> it gives me an error saying there is no module named mpi4py to import MPI.
> Any help .. ? How is it possible to run python program parallelized with
> mpi4py with python3.

You have to install mpi4py for "python3", i.e. use "python3 setup.py
install" or perhaps "python3 -m pip install mpi4py". In other words,
if you install a package for python(2), that does not make it
available in python3, you have to install it again.


--
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Numerical Porous Media Center (NumPor)
King Abdullah University of Science and Technology (KAUST)
http://numpor.kaust.edu.sa/

4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 4332
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa

Office Phone: +966 12 808-0459

Aditya Ghantasala

unread,
Sep 29, 2014, 3:33:17 AM9/29/14
to mpi...@googlegroups.com
Thank you Lisandro

I installed mpi4py for python3 and am using it now with in my program.
Reply all
Reply to author
Forward
0 new messages