Error loading MPI DLL in mpi4py











up vote
4
down vote

favorite
1












I am trying to use Mpi4py 1.3 with python 2.7 on Windows 7 64bits. I downloaded the installable version from here which includes OpenMPI 1.6.3 so in the installed directory (*/Python27Libsite-packagesmpi4pylib) following libraries exist: libmpi.lib, libmpi_cxx.lib, libopen-pal.lib, and libopen-rte.lib. Now in my codes when trying to import it:



from mpi4py import MPI


It returns following error:
ImportError: DLL load failed: The specified module could not be found. I tried to copy a bove lib files alongside the */Python27Libsite-packagesmpi4pyMPI.pyd and even to Windows/System32, but it didn't work. I appreciate your help on what DLL is missing and how to fix the error?



Thanks,



@Aso.agile










share|improve this question
























  • *.lib are either static library archives or import libraries. These are definitely not DLLs.
    – Hristo Iliev
    Dec 23 '12 at 9:16










  • Thanks @HristoIliev for your comment.You right *.lib are static library which in this case OpenMPI is provided in form of. Then what DLL is missing?
    – Aso Agile
    Dec 23 '12 at 12:40












  • Sorry, never used mpi4py, lest on Windows. Check the installation directory. May be there is a bitness mismatch (there were some Windows installation problems discussed recently on the Open MPI mailing lists...)
    – Hristo Iliev
    Dec 23 '12 at 20:50















up vote
4
down vote

favorite
1












I am trying to use Mpi4py 1.3 with python 2.7 on Windows 7 64bits. I downloaded the installable version from here which includes OpenMPI 1.6.3 so in the installed directory (*/Python27Libsite-packagesmpi4pylib) following libraries exist: libmpi.lib, libmpi_cxx.lib, libopen-pal.lib, and libopen-rte.lib. Now in my codes when trying to import it:



from mpi4py import MPI


It returns following error:
ImportError: DLL load failed: The specified module could not be found. I tried to copy a bove lib files alongside the */Python27Libsite-packagesmpi4pyMPI.pyd and even to Windows/System32, but it didn't work. I appreciate your help on what DLL is missing and how to fix the error?



Thanks,



@Aso.agile










share|improve this question
























  • *.lib are either static library archives or import libraries. These are definitely not DLLs.
    – Hristo Iliev
    Dec 23 '12 at 9:16










  • Thanks @HristoIliev for your comment.You right *.lib are static library which in this case OpenMPI is provided in form of. Then what DLL is missing?
    – Aso Agile
    Dec 23 '12 at 12:40












  • Sorry, never used mpi4py, lest on Windows. Check the installation directory. May be there is a bitness mismatch (there were some Windows installation problems discussed recently on the Open MPI mailing lists...)
    – Hristo Iliev
    Dec 23 '12 at 20:50













up vote
4
down vote

favorite
1









up vote
4
down vote

favorite
1






1





I am trying to use Mpi4py 1.3 with python 2.7 on Windows 7 64bits. I downloaded the installable version from here which includes OpenMPI 1.6.3 so in the installed directory (*/Python27Libsite-packagesmpi4pylib) following libraries exist: libmpi.lib, libmpi_cxx.lib, libopen-pal.lib, and libopen-rte.lib. Now in my codes when trying to import it:



from mpi4py import MPI


It returns following error:
ImportError: DLL load failed: The specified module could not be found. I tried to copy a bove lib files alongside the */Python27Libsite-packagesmpi4pyMPI.pyd and even to Windows/System32, but it didn't work. I appreciate your help on what DLL is missing and how to fix the error?



Thanks,



@Aso.agile










share|improve this question















I am trying to use Mpi4py 1.3 with python 2.7 on Windows 7 64bits. I downloaded the installable version from here which includes OpenMPI 1.6.3 so in the installed directory (*/Python27Libsite-packagesmpi4pylib) following libraries exist: libmpi.lib, libmpi_cxx.lib, libopen-pal.lib, and libopen-rte.lib. Now in my codes when trying to import it:



from mpi4py import MPI


It returns following error:
ImportError: DLL load failed: The specified module could not be found. I tried to copy a bove lib files alongside the */Python27Libsite-packagesmpi4pyMPI.pyd and even to Windows/System32, but it didn't work. I appreciate your help on what DLL is missing and how to fix the error?



Thanks,



@Aso.agile







python python-2.7 openmpi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 23 '12 at 12:37

























asked Dec 22 '12 at 16:23









Aso Agile

142412




142412












  • *.lib are either static library archives or import libraries. These are definitely not DLLs.
    – Hristo Iliev
    Dec 23 '12 at 9:16










  • Thanks @HristoIliev for your comment.You right *.lib are static library which in this case OpenMPI is provided in form of. Then what DLL is missing?
    – Aso Agile
    Dec 23 '12 at 12:40












  • Sorry, never used mpi4py, lest on Windows. Check the installation directory. May be there is a bitness mismatch (there were some Windows installation problems discussed recently on the Open MPI mailing lists...)
    – Hristo Iliev
    Dec 23 '12 at 20:50


















  • *.lib are either static library archives or import libraries. These are definitely not DLLs.
    – Hristo Iliev
    Dec 23 '12 at 9:16










  • Thanks @HristoIliev for your comment.You right *.lib are static library which in this case OpenMPI is provided in form of. Then what DLL is missing?
    – Aso Agile
    Dec 23 '12 at 12:40












  • Sorry, never used mpi4py, lest on Windows. Check the installation directory. May be there is a bitness mismatch (there were some Windows installation problems discussed recently on the Open MPI mailing lists...)
    – Hristo Iliev
    Dec 23 '12 at 20:50
















*.lib are either static library archives or import libraries. These are definitely not DLLs.
– Hristo Iliev
Dec 23 '12 at 9:16




*.lib are either static library archives or import libraries. These are definitely not DLLs.
– Hristo Iliev
Dec 23 '12 at 9:16












Thanks @HristoIliev for your comment.You right *.lib are static library which in this case OpenMPI is provided in form of. Then what DLL is missing?
– Aso Agile
Dec 23 '12 at 12:40






Thanks @HristoIliev for your comment.You right *.lib are static library which in this case OpenMPI is provided in form of. Then what DLL is missing?
– Aso Agile
Dec 23 '12 at 12:40














Sorry, never used mpi4py, lest on Windows. Check the installation directory. May be there is a bitness mismatch (there were some Windows installation problems discussed recently on the Open MPI mailing lists...)
– Hristo Iliev
Dec 23 '12 at 20:50




Sorry, never used mpi4py, lest on Windows. Check the installation directory. May be there is a bitness mismatch (there were some Windows installation problems discussed recently on the Open MPI mailing lists...)
– Hristo Iliev
Dec 23 '12 at 20:50












1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Use sys.prefixlibsite-packagesmpi4pybinpython-mpi.exe or add the following code to sys.prefixlibsite-packagesmpi4py__init__.py around line 37:



def _init_openmpi():
"""Pre-load libmpi.dll and register OpenMPI distribution."""
import os
import ctypes
if os.name != 'nt' or 'OPENMPI_HOME' in os.environ:
return
try:
openmpi_home = os.path.abspath(os.path.dirname(__file__))
openmpi_bin = os.path.join(openmpi_home, 'bin')
os.environ['OPENMPI_HOME'] = openmpi_home
os.environ['PATH'] = ';'.join((openmpi_bin, os.environ['PATH']))
ctypes.cdll.LoadLibrary(os.path.join(openmpi_bin, 'libmpi.dll'))
except Exception:
pass

_init_openmpi()





share|improve this answer























  • I tried this, I added the code both before before and after the def get_include(): function, but it doesn't work. I don't quite get the first solution you propose.
    – Toke Faurby
    Jul 10 at 11:45












  • This answer is long obsolete. It applies to a 5 year old binary of mpi4py that was linked to OpenMPI.
    – cgohlke
    Jul 11 at 6:47










  • Makes sense, but do you have an idea as to how to fix it now?
    – Toke Faurby
    Jul 11 at 10:15











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14004457%2ferror-loading-mpi-dll-in-mpi4py%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










Use sys.prefixlibsite-packagesmpi4pybinpython-mpi.exe or add the following code to sys.prefixlibsite-packagesmpi4py__init__.py around line 37:



def _init_openmpi():
"""Pre-load libmpi.dll and register OpenMPI distribution."""
import os
import ctypes
if os.name != 'nt' or 'OPENMPI_HOME' in os.environ:
return
try:
openmpi_home = os.path.abspath(os.path.dirname(__file__))
openmpi_bin = os.path.join(openmpi_home, 'bin')
os.environ['OPENMPI_HOME'] = openmpi_home
os.environ['PATH'] = ';'.join((openmpi_bin, os.environ['PATH']))
ctypes.cdll.LoadLibrary(os.path.join(openmpi_bin, 'libmpi.dll'))
except Exception:
pass

_init_openmpi()





share|improve this answer























  • I tried this, I added the code both before before and after the def get_include(): function, but it doesn't work. I don't quite get the first solution you propose.
    – Toke Faurby
    Jul 10 at 11:45












  • This answer is long obsolete. It applies to a 5 year old binary of mpi4py that was linked to OpenMPI.
    – cgohlke
    Jul 11 at 6:47










  • Makes sense, but do you have an idea as to how to fix it now?
    – Toke Faurby
    Jul 11 at 10:15















up vote
2
down vote



accepted










Use sys.prefixlibsite-packagesmpi4pybinpython-mpi.exe or add the following code to sys.prefixlibsite-packagesmpi4py__init__.py around line 37:



def _init_openmpi():
"""Pre-load libmpi.dll and register OpenMPI distribution."""
import os
import ctypes
if os.name != 'nt' or 'OPENMPI_HOME' in os.environ:
return
try:
openmpi_home = os.path.abspath(os.path.dirname(__file__))
openmpi_bin = os.path.join(openmpi_home, 'bin')
os.environ['OPENMPI_HOME'] = openmpi_home
os.environ['PATH'] = ';'.join((openmpi_bin, os.environ['PATH']))
ctypes.cdll.LoadLibrary(os.path.join(openmpi_bin, 'libmpi.dll'))
except Exception:
pass

_init_openmpi()





share|improve this answer























  • I tried this, I added the code both before before and after the def get_include(): function, but it doesn't work. I don't quite get the first solution you propose.
    – Toke Faurby
    Jul 10 at 11:45












  • This answer is long obsolete. It applies to a 5 year old binary of mpi4py that was linked to OpenMPI.
    – cgohlke
    Jul 11 at 6:47










  • Makes sense, but do you have an idea as to how to fix it now?
    – Toke Faurby
    Jul 11 at 10:15













up vote
2
down vote



accepted







up vote
2
down vote



accepted






Use sys.prefixlibsite-packagesmpi4pybinpython-mpi.exe or add the following code to sys.prefixlibsite-packagesmpi4py__init__.py around line 37:



def _init_openmpi():
"""Pre-load libmpi.dll and register OpenMPI distribution."""
import os
import ctypes
if os.name != 'nt' or 'OPENMPI_HOME' in os.environ:
return
try:
openmpi_home = os.path.abspath(os.path.dirname(__file__))
openmpi_bin = os.path.join(openmpi_home, 'bin')
os.environ['OPENMPI_HOME'] = openmpi_home
os.environ['PATH'] = ';'.join((openmpi_bin, os.environ['PATH']))
ctypes.cdll.LoadLibrary(os.path.join(openmpi_bin, 'libmpi.dll'))
except Exception:
pass

_init_openmpi()





share|improve this answer














Use sys.prefixlibsite-packagesmpi4pybinpython-mpi.exe or add the following code to sys.prefixlibsite-packagesmpi4py__init__.py around line 37:



def _init_openmpi():
"""Pre-load libmpi.dll and register OpenMPI distribution."""
import os
import ctypes
if os.name != 'nt' or 'OPENMPI_HOME' in os.environ:
return
try:
openmpi_home = os.path.abspath(os.path.dirname(__file__))
openmpi_bin = os.path.join(openmpi_home, 'bin')
os.environ['OPENMPI_HOME'] = openmpi_home
os.environ['PATH'] = ';'.join((openmpi_bin, os.environ['PATH']))
ctypes.cdll.LoadLibrary(os.path.join(openmpi_bin, 'libmpi.dll'))
except Exception:
pass

_init_openmpi()






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 8 '13 at 15:47

























answered Jan 8 '13 at 15:23









cgohlke

7,62012424




7,62012424












  • I tried this, I added the code both before before and after the def get_include(): function, but it doesn't work. I don't quite get the first solution you propose.
    – Toke Faurby
    Jul 10 at 11:45












  • This answer is long obsolete. It applies to a 5 year old binary of mpi4py that was linked to OpenMPI.
    – cgohlke
    Jul 11 at 6:47










  • Makes sense, but do you have an idea as to how to fix it now?
    – Toke Faurby
    Jul 11 at 10:15


















  • I tried this, I added the code both before before and after the def get_include(): function, but it doesn't work. I don't quite get the first solution you propose.
    – Toke Faurby
    Jul 10 at 11:45












  • This answer is long obsolete. It applies to a 5 year old binary of mpi4py that was linked to OpenMPI.
    – cgohlke
    Jul 11 at 6:47










  • Makes sense, but do you have an idea as to how to fix it now?
    – Toke Faurby
    Jul 11 at 10:15
















I tried this, I added the code both before before and after the def get_include(): function, but it doesn't work. I don't quite get the first solution you propose.
– Toke Faurby
Jul 10 at 11:45






I tried this, I added the code both before before and after the def get_include(): function, but it doesn't work. I don't quite get the first solution you propose.
– Toke Faurby
Jul 10 at 11:45














This answer is long obsolete. It applies to a 5 year old binary of mpi4py that was linked to OpenMPI.
– cgohlke
Jul 11 at 6:47




This answer is long obsolete. It applies to a 5 year old binary of mpi4py that was linked to OpenMPI.
– cgohlke
Jul 11 at 6:47












Makes sense, but do you have an idea as to how to fix it now?
– Toke Faurby
Jul 11 at 10:15




Makes sense, but do you have an idea as to how to fix it now?
– Toke Faurby
Jul 11 at 10:15


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14004457%2ferror-loading-mpi-dll-in-mpi4py%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

Alexandru Averescu

Trompette piccolo