【发布时间】:2012-03-23 20:35:18
【问题描述】:
我正在尝试开始使用 cython 并尝试编译我的第一个程序。我用以下代码创建了一个 hello.pyx:
def show():
print ("Hello World")
以及带有以下代码的 setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("hello", ["hello.pyx"])]
setup(
name = 'Hello world app',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
两者都在我称为“cython 程序”的文件夹中,该文件夹位于 C:\Python32\cython 程序中。 Cython 位于 C:\Python32\Lib\site-packages\Cython。但是,当我运行 setup.py 时,出现以下错误:
Traceback (most recent call last):
File "C:\Python32\cython programs\setup.py", line 10, in <module>
ext_modules = ext_modules
File "C:\Python32\lib\distutils\core.py", line 136, in setup
raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied
我猜我错过了一些非常简单的东西,但我似乎无法弄清楚它是什么。任何帮助将不胜感激。
【问题讨论】:
-
我认为您没有在命令行中为 setup.py 提供任何参数?
-
根据 cython 文档,您必须使用
build_ext参数。如果这是您的问题,您可能应该接受@Henry Gomersall 的回答。
标签: python compiler-errors cython