[Numpy-discussion] dll load failed when loading numpy in embedded python

Christoph Gohlke cgohlke@uci....
Mon Sep 6 02:07:50 CDT 2010



On 9/5/2010 11:27 PM, Jean-François MAUREL wrote:
>    Hi everyone,
>
> I get the error: 'DLL load failed' when loading numpy in embedded
> python. I could not find a solution in the archive.
> Any help appreciated.
>
> I have written a test as follows (borrowed from an other post):
> #include<stdlib.h>
> #include<stdio.h>
> #include<Python.h>
>
> int load(){
>     PyObject *errobj, *errdata, *errtraceback;
>     char* code = "import numpy\n";
>     Py_Initialize();
>     PyObject *m = PyImport_AddModule("__main__");
>     PyObject* d = PyModule_GetDict( m );
>     PyObject * resu = PyRun_String( code, Py_file_input, d, d);
>     PyErr_Fetch (&errobj,&errdata,&errtraceback);
>     if (errdata != NULL){
>       PyObject *s = PyObject_Str(errdata);
>       char * c = PyString_AS_STRING(s);
>       printf("%s\n",c);
>       Py_DECREF(s);
>     }else{
>       printf("no errors.\n");
>     }
>     Py_XDECREF(errobj);
>     Py_XDECREF(errdata);
>     Py_XDECREF(errtraceback);
>     Py_Finalize();
>     return 0;
> }
>
> int main(int argc, char **argv){
>     load();
>     return 0;
> }
>
> this is build using:
> gcc -I/openSource/python26/include -ggdb -c t.c -oc.o -Wall
> gcc c.o C:\openSource\python26\libs\libpython26.a -otest.exe -Wall
>
> configuration is:
> windows vista
> mingw gcc 4.5.0
> python 2.6
> numpy 1.5
>

Your test program worked for me. Try opening the file test.exe with 
Dependecy Walker <http://www.dependencywalker.com/> and see which DLLs 
are found or missing.

Christoph


More information about the NumPy-Discussion mailing list