我为我的Python创建了扩展并创建了一个abcPython.dll.如何将此dll导入我的Python脚本?
当我尝试使用以下命令导入它时收到错误消息
>>>import abcPython
>>>Traceback (most recent call last):
File "", line 1, in
ImportError: No module named abcPython
>>>
我手动创建了一个名为PYTHONPATH的系统环境变量,它存储了abcPython.dll的路径,但仍然存在错误.
我怎样才能解决这个问题?
解决方法:
The output file should be called spam.pyd (in Release mode) or spam_d.pyd (in Debug mode). The extension .pyd was chosen to avoid confusion with a system library spam.dll to which your module could be a Python interface
…
Changed in version 2.5: Previously, file names like spam.dll (in release mode) or spam_d.dll (in debug mode) were also recognized.
尝试重命名您的DLL以使用.pyd扩展名而不是.dll.
引用指向C example,它明确包含INIT函数,
PyMODINIT_FUNC initexample(void).生成的DLL应重命名为example.pyd:
#include "Python.h&