我想開始使用cython並試圖編譯我的第一個程序。我已經創建了下面的代碼hello.pyx:編譯第一個cython程序時出錯
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任何參數? – 2012-03-23 23:13:52
根據cython文檔,你必須使用'build_ext'參數。如果這是你的問題,你應該接受@Henry Gomersall的回答。 – 2012-03-23 23:18:16