0

I am brand new to parallel computing and I'm trying to set up a small cluster of Raspberry Pi's to fiddle around with. Whenever I went to install mpi4py, I used pip3 install mpi4py but I am still getting the following error when I try to run a simple test script. I am able to use mpiexec with a Hello World script that prints "Hello" for every core in the cluster.

Hardware is a cluster Raspberry Pi 3B+ running Rasbian Lite

test.py:

from mpi4py import MPI

print("Test")

This is the readout that I am getting from the command line:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from mpi4py import MPI
ImportError: No module named mpi4py

Thanks in advance

6
  • 1
    How are you running the script? Is it with the version of python that reads from the library that pip3 installs to? Commented Apr 22, 2022 at 16:37
  • 2
    I always use python -m pip install to make sure packages end up in the right python installation. Commented Apr 22, 2022 at 16:37
  • Does this answer your question? Python beginner - No module named 'mpi4py' Commented Apr 22, 2022 at 16:39
  • try python -m pip install mpi4py Commented Apr 22, 2022 at 16:51
  • @chepner I am running the script with mpiexec -hostlist nodes_ips python test.py When I try to run python -m pip install mpi4py, I am getting an error that there is not module named 'pip' Commented Apr 22, 2022 at 17:01

1 Answer 1

1

I found the solution, and frankly I feel a little silly now. I wasn't aware that Debian for Raspberry Pi comes preinstalled with both Python 2 and Python 3, so I have run to mpiexec -hostlist nodes_ips python3 test.py instead.

Sign up to request clarification or add additional context in comments.

1 Comment

Maybe it's Python and distros which are a bit silly here. But yes you used pip3 explicitly so that goes with explicit python3. Luckily the painful 2-> 3 transition is I guess pretty much done finally now, and maybe some time before year 3000 there's only 3 and that also as default everywhere (py 3 project was called Python 3000 initially).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.