RuntimeError: Error when importing mpi4py

Could you please suggest how to fix this error?

RuntimeError: Error when importing mpi4py

The general principle is that you need to make sure your system is compiled consistently with the various packages and libraries that it uses. This quality is what the package distributions are intended to provide, e.g. ubuntu (apt) or conda.

In general you should never use pip to install packages, since pip does not manage the full dependency chain of libraries. This is particularly the case when C libraries such as MPI are involved, not just pure python packages.

Don’t mix your package installation methods. Either use conda, or use apt, not both.

Don’t use pip to install packages.

1 Like