Error in building mpi4py package

41 views
Skip to first unread message

Saurabh Zond

unread,
Mar 25, 2023, 9:49:46 PM3/25/23
to mpi4py
Hi All,

I'm trying to build the mpi4py package by following the steps give on this page - 

https://mpi4py.readthedocs.io/en/stable/install.html

Here I installed the open_mpi package for mpicc and am using the following command to build - 

python setup.py build --mpi=open_mpi
( I have configured the mpi.cfg code as shown for open_mpi)

Here I'm facing the following issue-

src/mpi4py.MPI.c:6:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.


Here I tried a hack to copy a Python.h file from this source - 
https://github.com/python/cpython/blob/main/Include/Python.h

and place it in the src folder before giving the build command, but still I get similar error - 
In file included from src/MPI.c:4:0:src/mpi4py.MPI.c:8:6: error: #error Python headers needed to compile C extensions, please install development version of Python. #error Python headers needed to compile C extensions, please install development version of Python. ^error: command '/scratch/user/saurabh_zond/takde_setup/openmpi/bin/mpicc' failed with exit status 1
I tried googling this, and it mentions to install developer packages using - 

sudo apt-get install python3-dev

Now, I'm running on the college terminal, thus don't have the sudo access to install this.

Is there any roundabout to this problem/ Any Python.h that I can readily use?

Look forward to hear from others.

Regards,
Saurabh Zond


Yury V. Zaytsev

unread,
Mar 26, 2023, 4:44:40 AM3/26/23
to mpi4py
On Sat, 25 Mar 2023, Saurabh Zond wrote:

> Now, I'm running on the college terminal, thus don't have the sudo
> access to install this. Is there any roundabout to this problem/ Any
> Python.h that I can readily use?

If your college indeed cannot provide you with a working system Python
installation including development headers, then your only option is to
use an own Python installation from your home directory.

For instance, you can use miniconda:

https://docs.conda.io/en/latest/miniconda.html

Just create a separate virtual enviroment for your experiments to not to
trash your main installation (root environment).

--
Sincerely yours,
Yury V. Zaytsev

Saurabh Zond

unread,
Mar 27, 2023, 12:08:09 PM3/27/23
to mpi4py
Thanks for the update. So I can install the mini conda on my college's linux and use it to set up my environment.
 I can still access the college's servers through this, right? As I'll need them for the multi-threading application in the script.

Looking forward to hear from you.

Regards.

Yury V. Zaytsev

unread,
Mar 27, 2023, 12:14:20 PM3/27/23
to mpi4py
On Mon, 27 Mar 2023, Saurabh Zond wrote:

> Thanks for the update. So I can install the mini conda on my college's
> linux and use it to set up my environment. I can still access the
> college's servers through this, right? As I'll need them for the
> multi-threading application in the script. Looking forward to hear from
> you.

Only your college IT support can answer this question, but I see no reason
why the answer would be "no".
Reply all
Reply to author
Forward
0 new messages