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

天涯浪子 提交于 2021-02-05 11:34:10

问题


I am using Python 3 on CentOS 7. I am trying to build a C extension as described here. I have written a simple program, demo.c, which is in a directory in PYTHONPATH. demo.c has the following form.

#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

回答1:


The error is saying you'll need to pass in a Distutils command, such as build (or probably build_ext in your case).

python CInterface.py build_ext


来源:https://stackoverflow.com/questions/58717898/error-no-commands-supplied-when-using-distutils-core

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!