"error: no commands supplied" when using distutils.core
"error: no commands supplied" when using distutils.core
我在 CentOS 7 上使用 Python 3。我正在尝试按照 here 所述构建 C 扩展。我写了一个简单的程序,demo.c,它在 PYTHONPATH 的一个目录中。 demo.c 具有以下形式。
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello from demo.c\n");
return 0;
}
这段代码运行没有错误。
from distutils.core import setup, Extension
module1 = Extension('demo',
sources = ['demo.c'])
但是下面的代码
setup (name = 'PackageName',
version = '1.0',
description = 'This is a demo package',
ext_modules = [module1])
产生以下错误。
An exception has occurred, use %tb to see the full traceback.
SystemExit: usage: CInterface.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: CInterface.py --help [cmd1 cmd2 ...]
or: CInterface.py --help-commands
or: CInterface.py cmd --help
error: no commands supplied
错误提示您需要传入 Distutils 命令,例如 build
(or probably build_ext
in your case).
python CInterface.py build_ext
我在 CentOS 7 上使用 Python 3。我正在尝试按照 here 所述构建 C 扩展。我写了一个简单的程序,demo.c,它在 PYTHONPATH 的一个目录中。 demo.c 具有以下形式。
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello from demo.c\n");
return 0;
}
这段代码运行没有错误。
from distutils.core import setup, Extension
module1 = Extension('demo',
sources = ['demo.c'])
但是下面的代码
setup (name = 'PackageName',
version = '1.0',
description = 'This is a demo package',
ext_modules = [module1])
产生以下错误。
An exception has occurred, use %tb to see the full traceback.
SystemExit: usage: CInterface.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: CInterface.py --help [cmd1 cmd2 ...]
or: CInterface.py --help-commands
or: CInterface.py cmd --help
error: no commands supplied
错误提示您需要传入 Distutils 命令,例如 build
(or probably build_ext
in your case).
python CInterface.py build_ext