我正在尝试让Cython意识到我在MinGW 32位中有一个C编译器,我已经尝试了我能在网上找到的所有方法,但它仍然不起作用。我运行的是Windows 7 Professional 64位。这是我尝试过的内容:
(1)我有Python 2.7,我刚刚安装了带有gcc和g ++选项以及其他一些选项的MinGW。
(2)我编辑了PATH环境变量,以便包括
(1)我有Python 2.7,我刚刚安装了带有gcc和g ++选项以及其他一些选项的MinGW。
(2)我编辑了PATH环境变量,以便包括
C:\MinGW\bin;C:\MinGW\MSYS\1.0\local\bin;C:\MinGW\MSYS\1.0\bin
(3) 我告诉Python使用MinGW作为默认编译器,方法是创建一个名为
C:\Python27\Lib\distutils\distutils.cfg的文件,并将以下内容写入其中:
[build]
compiler = mingw32
(我顺便提一下,我有MinGW32)
(4) 我从文件C:\Python27\Lib\distutils\cygwincompiler.py中删除了所有“-mno-cygwin”的实例
(5) 我有一个名为setup.py的文件和一个名为tryingcython.pyx的模块,后者用python编写。我的setup.py文件中包含以下内容: from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext
setup(
cmdclass = {'build_ext':build_ext},
ext_modules=[Extension("tryingcython",["tryingcython.pyx"])]
)
那么我打开命令提示符,进入包含setup.py和tryingcython.pyx的目录,并输入以下命令:
python setup.py build_ext --inplace --compiler=mingw32
然后它告诉我:
running build_ext
skipping 'tryingcython.c' Cython extension (up-to-date)
building 'tryingcython.c' extension
gcc -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c tryingcython.c -o build\
temp.win32-2.7\Release\tryingcython.o
error: command 'gcc' failed: No such file or directory
所以我猜测Cython可能无法检测到我已经安装了gcc,因此它找不到它,尽管我已经尝试了网上每一条与让它意识到我已经安装了包含gcc的MinGW相关的建议。如果您有任何帮助或额外的想法,以使Cython真正可用,将不胜感激。
C:\> gcc.exe
)?一般来说,我会使用Anaconda这样的发行版,它带有编译Cython模块所需的所有工具。 - joon