DLL load failed: The specified module could not be found when doing "from mpi4py import MPI"

Using Mpi4py 1.3 with python 3.5 on Windows 10, I can run import mpi4py successfully but not from mpi4py import MPI. To fix it, just reinstall MPI via MPI. This works for me.


I solved the problem. My environment is Win10, python 3.6.6, pycharm 2019.2 and linked to annaconda visual env.
1. download MS MPI, install both .mis and SDK.
2. set up environmental variables
control panel --> advanced system settings --> environmental variables --> add
(1) C:\Program Files (x86)\Microsoft SDKs\MPI and
(2) C:\Program Files\Microsoft MPI\Bin. There are my paht, you may need to change the path here.
3. install MS visual studio, community version is enough
4. Anaconda prompt, use conda install -c intel mpi4py. I read most replies but not mentioned this way.


I had the same issue and no answer solved the issue.

For me, the following solved the problem. I compiled and installed the mpi4py manually as follows:

  • Install MPI SDK 10 for Windows from https://duongtrungnghia.wordpress.com/2017/03/28/install-mpi4py-on-windows-10/
  • Add C:\Program Files (x86)\Microsoft SDKs\MPI\Lib and C:\Program Files (x86)\Microsoft SDKs\MPI to your Windows environment variables (not sure if needed)
  • You need Visual Studio Build Tools with MSVC 140 or pure Visual Studio. Not sure what version. In my case, the mpi4py setup.py used C:\Program Files (x86)\Microsoft Visual Studio 14.0\.... although I use VS2017 currently.
  • Install Windows SDK/Kits and dev tools (https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)
    • Open Developer Command Prompt (It is like a CMD with some extras)
    • Activate your venv by executing (venv/Scripts/activate) if you use Virtualenv
    • Create and change to a temp directory and do the following:
      • git clone https://github.com/mpi4py/mpi4py.git
      • cd mpi4py
      • python -m pip install Cython
      • python setup.py build
      • python setup.py install

My setting:

  • Windows 10
  • Python 3.7