Compile the extension module (Dynamic Link Library) for Python using C ++ and call the extension function developed by C ++ in Python. the following error occurs, is it annoying:
Traceback (most recent calllast ):
File "t. py", line 6, in <module>
Import Rabbit
ImportError: No modulenamed Rabbit
Possible causes include:
1. If Python2.5 is used during development, check whether the generated dynamic library extension is "pyd". (If the suffix is dll, modify it );
2. In the source code of DLLMAIN, export the initialization code of the extension module:
# Ifdef PYRABBIT_EXPORTS
# Define PYRABBIT_API _ declspec (dllexport)
# Else
# DefinePYRABBIT _ declspec (dllimport)
# Endif
Extern "C" PYRABBIT_API void initRabbit (){
PyObject * m = Py_InitModule ("Rabbit", RabbitMethods );
}
3. The generated dynamic library file (suffixed with pyd) is not included in the environment variable. You can run the following command on the console to check the file;
Import OS
OS. sys. path
From bored blogs