【发布时间】:2020-02-27 20:23:04
【问题描述】:
我为我的 CPython 扩展编写了以下代码:
#include <Python.h>
static PyObject *greeting(PyObject* self)
{
return Py_BuildValue("s" , "Hello python modules!!!");
}
static char *my_docstring = "This is a sample docstring";
static PyMethodDef greeting_funcs[] = {
{"greeting" , (PyCFunction)greeting , METH_NOARGS , my_docstring} , {NULL}
};
void initModule(void){
Py_InitModule3("greeting" , greeting_funcs , "Module example!!!");
}
当我在 IPython3 shell 中执行以下操作时
from setuptools import setup , Extension
modules = [Extension('mod', sources=["/home/spm/python_module/mod.c"])]
setup(ext_modules=modules)
我得到了错误:
SystemExit: usage: ipython3 [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts]
or: ipython3 --help [cmd1 cmd2 ...]
or: ipython3 --help-commands
or: ipython3 cmd --help
error: no commands supplied
任何帮助表示赞赏。
谢谢。
【问题讨论】:
标签: c python-3.x setuptools python-extensions