Cython" HelloWorld"示例没有运行,但编译器?

时间:2018-03-18 16:25:22

标签: python gcc mingw cython

cython" Hello World"来自http://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html的示例 我的Windows系统上没有运行,而编译器工作

任何提示都很受欢迎,我试着用了好几天...

更详细地说:

海湾合作委员会似乎在Windows上工作;因为编译这个C示例有效:

#include <stdio.h>

int main (){
    printf("Hello world");
    return 0;

}

现在回到Cython示例: 它适用于Ubuntu,但在windows中引发了以下错误:

Compiling helloworld.pyx because it changed.
[1/1] Cythonizing helloworld.pyx
running build_ext
building 'helloworld' extension
creating build
creating build\temp.win32-3.6
creating build\temp.win32-3.6\Release
C:\MinGW\bin\gcc.exe -mdll -O -Wall -DMS_WIN32 -IC:\Users\Tom\Anaconda3\include
-IC:\Users\Tom\Anaconda3\include -c helloworld.c -o build\temp.win32-3.6\Release
\helloworld.o
In file included from C:\Users\Tom\Anaconda3\include/Python.h:8:0,
                 from helloworld.c:16:
C:\Users\Tom\Anaconda3\include/pyconfig.h:68:0: Warnung: »MS_WIN32« redefiniert
 #define MS_WIN32 /* only support win32 and greater. */

<Kommandozeile>:0:0: Anmerkung: dies ist die Stelle der vorherigen Definition
In file included from C:\Users\Tom\Anaconda3\include/Python.h:65:0,
                 from helloworld.c:16:
C:\Users\Tom\Anaconda3\include/pytime.h:111:12: Warnung: »struct timeval« declar
ed inside parameter list will not be visible outside of this definition or decla
ration
     struct timeval *tv,
            ^~~~~~~
C:\Users\Tom\Anaconda3\include/pytime.h:116:12: Warnung: »struct timeval« declar
ed inside parameter list will not be visible outside of this definition or decla
ration
     struct timeval *tv,
            ^~~~~~~
writing build\temp.win32-3.6\Release\helloworld.cp36-win32.def
C:\MinGW\bin\gcc.exe -shared -s build\temp.win32-3.6\Release\helloworld.o build\
temp.win32-3.6\Release\helloworld.cp36-win32.def -LC:\Users\Tom\Anaconda3\libs -
LC:\Users\Tom\Anaconda3\PCbuild\win32 -lpython36 -lmsvcr140 -o "C:\Users\...\hw\helloworld.cp36-win32.pyd"
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot fin
d -lmsvcr140
collect2.exe: Fehler: ld gab 1 als Ende-Status zurück
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1

这里是hello world代码:

helloworld.pyx:

print("Hello World")

setup.py:

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

setup(
    ext_modules = cythonize("helloworld.pyx")
)

命令:

python setup.py build_ext --inplace

0 个答案:

没有答案