Oh, be very carefull, maybe some parts of your code is linking MPI
statically, that would be VERY bad.
Instead of LD_PRELOAD, you could try the following (at the very
beginning of your script)
from mpi4py import MPI
from mpi4py import dl
lib = dl.dlopen("libmpi.so.1", dl.RTLD_GLOBAL|dl.RTLD_NOW|dl.RTLD_NOLOAD)
assert lib, dl.dlerror()
Of course, replace "libmpi.so.1" with the actual name of the library,
i.e. the one you used with LD_PRELOAD, or the one you get from ldd on
mpi4py's MPI.so extension module.
Anyway, this is just a workaround. I still think some of your modules
are linking MPI statically, that's the reason you see these errors.