Skip to content Skip to sidebar Skip to footer

Swig No Module Named _example

I cannot reproduce the basic SWIG example on windows. My error is stated in the SWIG docs and I am sure that I do the 2 fixes they mention. For this error: >>> import exam

Solution 1:

The file name of the library must be *.pyd. I suppose that you have generated a wrapper code and link it together.

Solution 2:

I found that (in windows), if you make a dll it has to be called _modulename.pyd This library (_modulename.pyd), the original c++ module myapp.dll and the resulting modulename.py have to be in the path as well as pythonxx.exe

Solution 3:

I found you have to rename the library file that C++ generates from .dll to .pyd on windows. I can't recall if you need to rename it on apple. and your function that you want to expose to python has to have extern "C" preceding it. Otherwise the compiler doesn't make the function accessible outside the library. Also If I recall you need to wrap the return values in a Py_value if you want to use them in python.

Post a Comment for "Swig No Module Named _example"