2

我正在尝试在 Windows 10 上使用 Cython 编译一个 hello world 示例。我有 Visual Studio 2015 社区。Python 3.5.2

我的 setup.py 看起来像这样:

from distutils.core import setup
from Cython.Build import cythonize

setup (
   name='print hello world',
   ext_modules=cythonize("print_h_w.pyx", compiler_directives=
   {'language_level': 3}),
)

我要编译的文件如下所示:

print('Hello World')

我用这个命令构建:

python setup.py build_ext --inplace

我不断收到此错误:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe 
/c /nologo /Ox /W3 /GL /DNDEBUG /MD -
IC:\Users\Paul\AppData\Local\Programs\Python\Python35\include -
IC:\Users\Paul\AppData\Local\Programs\Python\Python35\include "-IC:\Program 
Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files 
(x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files 
(x86)\Windows Kits\10\include\10.0.14393.0\ucrt" "-IC:\Program Files 
(x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files 
(x86)\Windows Kits\10\include\10.0.14393.0\shared" "-IC:\Program Files 
(x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Program Files 
(x86)\Windows Kits\10\include\10.0.14393.0\winrt" "-IC:\Program Files 
(x86)\Windows Kits\10\Include\10.0.14393.0\ucrt\" /Tcprint_h_w.c 
/Fobuild\temp.win-amd64-3.5\Release\print_h_w.obj
cl : Command line error D8003 : missing source filename
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 
14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

我一直在做很多研究,但我发现了很多什么都没有。我怎样才能解决这个问题?

4

1 回答 1

0

我认为您应该cythonprint_h_w.pyx文件中导入:

import cython
print("hello world")
于 2017-05-26T10:01:28.353 回答