No attribute '__qualname__' on mpi4py 3.1.6

Dear all,

I built in virtual environment with Python 3.10.14 dolfinx 0.8.0.

I get this type of error

>>> from mpi4py import MPI
>>> mpi4py.MPI.Get_version()
(3, 1)
>>> from dolfinx import mesh
>>> domain = mesh.create_unit_square(MPI.COMM_WORLD, 8, 8, mesh.CellType.quadrilateral)
terminate called after throwing an instance of 'nanobind::python_error'
  what():  AttributeError: type object 'CellType' has no attribute '__qualname__'

I found the same error with mpi4py 4, but I has version 3.1.6

OS CentOS 7.9
gcc 11.2.0
OpenMPI 4.1.1

The installed packages in virtual environment

$ conda list
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main
_openmp_mutex             5.1                       1_gnu
bzip2                     1.0.8                h5eee18b_6
ca-certificates           2024.7.2             h06a4308_0
cffi                      1.17.1                   pypi_0    pypi
exceptiongroup            1.2.2                    pypi_0    pypi
fenics-basix              0.8.0                    pypi_0    pypi
fenics-dolfinx            0.8.0                    pypi_0    pypi
fenics-ffcx               0.8.0                    pypi_0    pypi
fenics-ufl                2024.1.0                 pypi_0    pypi
gmp                       6.2.1                h295c915_3
gmpy2                     2.1.2           py310heeb90bb_0
iniconfig                 2.0.0                    pypi_0    pypi
ld_impl_linux-64          2.38                 h1181459_1
libffi                    3.4.4                h6a678d5_1
libgcc-ng                 11.2.0               h1234567_1
libgomp                   11.2.0               h1234567_1
libstdcxx-ng              11.2.0               h1234567_1
libuuid                   1.41.5               h5eee18b_0
mpc                       1.1.0                h10f8cd9_1
mpfr                      4.0.2                hb69a4c5_1
mpi4py                    3.1.6                    pypi_0    pypi
mpmath                    1.3.0           py310h06a4308_0
nanobind                  1.9.2                    pypi_0    pypi
ncurses                   6.4                  h6a678d5_0
numpy                     2.0.0                    pypi_0    pypi
openssl                   3.0.15               h5eee18b_0
packaging                 24.1                     pypi_0    pypi
petsc4py                  3.21.3                   pypi_0    pypi
pip                       24.2            py310h06a4308_0
pluggy                    1.5.0                    pypi_0    pypi
pybind11                  2.12.0                   pypi_0    pypi
pycparser                 2.22                     pypi_0    pypi
pytest                    8.3.3                    pypi_0    pypi
python                    3.10.14              h955ad1f_1
readline                  8.2                  h5eee18b_0
setuptools                72.1.0          py310h06a4308_0
slepc4py                  3.21.1                   pypi_0    pypi
sqlite                    3.45.3               h5eee18b_0
sympy                     1.13.2          py310h06a4308_0
tk                        8.6.14               h39e8969_0
tomli                     2.0.1                    pypi_0    pypi
tzdata                    2024a                h04d1e81_0
wheel                     0.44.0          py310h06a4308_0
xz                        5.4.6                h5eee18b_1
zlib                      1.2.13               h5eee18b_1

This packages I built from sources and after this made pip install . where it was needed

  • basix-0.8.0
  • boost-1.85.0
  • dolfinx-0.8.0
  • ffcx-0.8.0
  • flex-2.6.4
  • hdf5-1.14.4.2
  • lapack-3.12.0
  • mpi4py-3.1.6
  • nanobind-1.9.2
  • petsc-3.21.3
  • pugixml-1.14
  • pybind11-2.12.0
  • scalapack-2.2.1
  • slepc-3.21.1
  • ufl-2024.1.0

We have seen this in the past at No attribute '__qualname__' due to mpi4py 4.0.0 , although the error there was about mpi4py 4.0, and downgrading to 3.1 fixed the issue.

Is there a specific reason why you are using mpi4py from pypi rather than from conda? It’s likely that the conda package expects mpi4py to be installed from conda rather than pypi.

Thank you for answer,

I installed mpi4py from sources via MPICC=$(which mpicc) pip install .
Now reinstall from conda (3.1.4). But error still the same.

I saw this task, but my version is 3.1.6.

Is there a reason you mix conda and source installation? It is not adviced as you need to be very careful about what mpi implementations are picked up.

Thank you in advance. Installation from conda is working correct.