简体   繁体   English

使用 distutils.core 时出现“错误:未提供命令”

[英]“error: no commands supplied” when using distutils.core

I am using Python 3 on CentOS 7. I am trying to build a C extension as described here .我在 CentOS 7 上使用 Python 3。我正在尝试构建一个 C 扩展,如此所述。 I have written a simple program, demo.c, which is in a directory in PYTHONPATH.我写了一个简单的程序,demo.c,它位于 PYTHONPATH 的一个目录中。 demo.c has the following form. demo.c 具有以下形式。

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("Hello from demo.c\n");
    return 0;
}

This code runs without error.此代码运行没有错误。

from distutils.core import setup, Extension

module1 = Extension('demo',
                sources = ['demo.c'])

However, the following code但是,下面的代码

setup (name = 'PackageName',
   version = '1.0',
   description = 'This is a demo package',
   ext_modules = [module1])

produces the following error.产生以下错误。

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

The error is saying you'll need to pass in a Distutils command, such as build (or probably build_ext in your case) .错误是说您需要传入 Distutils 命令,例如build (或者在您的情况下可能是build_ext )

python CInterface.py build_ext

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM