python中的gcc编译错误

python中的gcc编译错误,python,gcc,cygwin,Python,Gcc,Cygwin,我知道gcc上有很多线程,特别是“command gcc failed with exit status 1”,我已经查看了所有这些线程,但仍然无法修复这一问题。我只会将gcc或mingw32用于与python相关的任务,例如使用Cython或其他可能涉及编译的包。然而,它似乎从来都不起作用 我有一台装有Windows7家庭版的电脑。我已经用mingw32安装了cygwin,还安装了Visual Studio 11 Beta,我很乐意卸载/重新安装任何东西以使其正常工作 Cython编译总是以失

我知道gcc上有很多线程,特别是“command gcc failed with exit status 1”,我已经查看了所有这些线程,但仍然无法修复这一问题。我只会将gcc或mingw32用于与python相关的任务,例如使用Cython或其他可能涉及编译的包。然而,它似乎从来都不起作用

我有一台装有Windows7家庭版的电脑。我已经用mingw32安装了cygwin,还安装了Visual Studio 11 Beta,我很乐意卸载/重新安装任何东西以使其正常工作

Cython编译总是以失败告终

error: command 'gcc' failed with exit status 1
但是,即使尝试使用pip安装许多python软件包也会失败,并出现类似的错误。例如,我试图安装一个名为“xhtml2pdf”的软件包。在命令提示符下运行“pip install xhtml2pdf”后,出现以下错误:

copying src\reportlab\lib\hyphen.mashed -> build\lib.win32-2.7\reportlab\lib

running build_ext

building '_rl_accel' extension

C:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Pytho
n27\PC -c "C:\Users\JJ\Documents\Coding Fun\build\reportlab\src\rl_addons\rl_acc
el\_rl_accel.c" -o "c:\users\jj\documents\coding fun\build\reportlab\src\rl_addo
ns\rl_accel\_rl_accel.o"

cc1.exe: error: unrecognized command line option '-mno-cygwin'

error: command 'gcc' failed with exit status 1
从cygwin运行相同的命令会产生不同的错误:

copying src\reportlab\lib\hyphen.mashed -> build\lib.win32-2.7\reportlab\lib

running build_ext

building '_rl_accel' extension

gcc -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c C:\cygwin\home\JJ\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c -o c:\cygwin\home\jj\build\reportlab\src\rl_addons\rl_accel\_rl_accel.o

error: command 'gcc' failed: No such file or directory

----------------------------------------
Command C:\Python27\python.exe -c "import setuptools;__file__='C:\\cygwin\\home\\JJ\\build\\reportlab\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record c:\users\jj\appdata\local\temp\pip-aohmse-record\install-record.txt failed with error code 1 in C:\cygwin\home\JJ\build\reportlab
Storing complete log in C:\Users\JJ\AppData\Roaming\pip\pip.log


----------------------------------------
Command C:\Python27\python.exe -c "import setuptools;__file__='C:\\Users\\JJ\\Do
cuments\\Coding Fun\\build\\reportlab\\setup.py';exec(compile(open(__file__).rea
d().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-external
ly-managed --record c:\users\jj\appdata\local\temp\pip-r8_mri-record\install-rec
ord.txt failed with error code 1 in C:\Users\JJ\Documents\Coding Fun\build\repor
tlab
Storing complete log in C:\Users\JJ\AppData\Roaming\pip\pip.log
一般来说,我对编译非常陌生,只使用过解释性语言,所以我一直沮丧地无法自己解决这个问题。安装此软件包时,如有任何帮助,将不胜感激

编辑:我以前遵循过一些建议,比如尝试删除distutils中对“-mno cygwin”的所有引用,并创建distutils.cfg文件,但没有效果

更新:在重新安装cygwin并将gcc和g++的安装降级到v3之后,我得到了另一个不同的错误:

copying src\reportlab\lib\PyFontify.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\pygments2xpre.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\randomtext.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\rltempfile.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\rparsexml.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\sequencer.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\set_ops.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\styles.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\testutils.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\textsplit.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\units.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\utils.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\validators.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\xmllib.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\yaml.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\lib\__init__.py -> build\lib.win32-2.7\reportlab\lib

copying src\reportlab\pdfbase\cidfonts.py -> build\lib.win32-2.7\reportlab\pdfba
se

copying src\reportlab\pdfbase\pdfdoc.py -> build\lib.win32-2.7\reportlab\pdfbase


copying src\reportlab\pdfbase\pdfform.py -> build\lib.win32-2.7\reportlab\pdfbas
e

copying src\reportlab\pdfbase\pdfmetrics.py -> build\lib.win32-2.7\reportlab\pdf
base

copying src\reportlab\pdfbase\pdfpattern.py -> build\lib.win32-2.7\reportlab\pdf
base

copying src\reportlab\pdfbase\pdfutils.py -> build\lib.win32-2.7\reportlab\pdfba
se

copying src\reportlab\pdfbase\rl_codecs.py -> build\lib.win32-2.7\reportlab\pdfb
ase

copying src\reportlab\pdfbase\ttfonts.py -> build\lib.win32-2.7\reportlab\pdfbas
e

copying src\reportlab\pdfbase\_can_cmap_data.py -> build\lib.win32-2.7\reportlab
\pdfbase

copying src\reportlab\pdfbase\_cidfontdata.py -> build\lib.win32-2.7\reportlab\p
dfbase

copying src\reportlab\pdfbase\_fontdata.py -> build\lib.win32-2.7\reportlab\pdfb
ase

copying src\reportlab\pdfbase\_fontdata_enc_macexpert.py -> build\lib.win32-2.7\
reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_macroman.py -> build\lib.win32-2.7\r
eportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_pdfdoc.py -> build\lib.win32-2.7\rep
ortlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_standard.py -> build\lib.win32-2.7\r
eportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_symbol.py -> build\lib.win32-2.7\rep
ortlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_winansi.py -> build\lib.win32-2.7\re
portlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_enc_zapfdingbats.py -> build\lib.win32-2
.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_courier.py -> build\lib.win32-2.7
\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_courierbold.py -> build\lib.win32
-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_courierboldoblique.py -> build\li
b.win32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_courieroblique.py -> build\lib.wi
n32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_helvetica.py -> build\lib.win32-2
.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_helveticabold.py -> build\lib.win
32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_helveticaboldoblique.py -> build\
lib.win32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_helveticaoblique.py -> build\lib.
win32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_symbol.py -> build\lib.win32-2.7\
reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_timesbold.py -> build\lib.win32-2
.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_timesbolditalic.py -> build\lib.w
in32-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_timesitalic.py -> build\lib.win32
-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_timesroman.py -> build\lib.win32-
2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\_fontdata_widths_zapfdingbats.py -> build\lib.win3
2-2.7\reportlab\pdfbase

copying src\reportlab\pdfbase\__init__.py -> build\lib.win32-2.7\reportlab\pdfba
se

copying src\reportlab\pdfgen\canvas.py -> build\lib.win32-2.7\reportlab\pdfgen

copying src\reportlab\pdfgen\pathobject.py -> build\lib.win32-2.7\reportlab\pdfg
en

copying src\reportlab\pdfgen\pdfgeom.py -> build\lib.win32-2.7\reportlab\pdfgen

copying src\reportlab\pdfgen\pdfimages.py -> build\lib.win32-2.7\reportlab\pdfge
n

copying src\reportlab\pdfgen\pycanvas.py -> build\lib.win32-2.7\reportlab\pdfgen


copying src\reportlab\pdfgen\textobject.py -> build\lib.win32-2.7\reportlab\pdfg
en

copying src\reportlab\pdfgen\__init__.py -> build\lib.win32-2.7\reportlab\pdfgen


copying src\reportlab\platypus\doctemplate.py -> build\lib.win32-2.7\reportlab\p
latypus

copying src\reportlab\platypus\figures.py -> build\lib.win32-2.7\reportlab\platy
pus

copying src\reportlab\platypus\flowables.py -> build\lib.win32-2.7\reportlab\pla
typus

copying src\reportlab\platypus\frames.py -> build\lib.win32-2.7\reportlab\platyp
us

copying src\reportlab\platypus\para.py -> build\lib.win32-2.7\reportlab\platypus


copying src\reportlab\platypus\paragraph.py -> build\lib.win32-2.7\reportlab\pla
typus

copying src\reportlab\platypus\paraparser.py -> build\lib.win32-2.7\reportlab\pl
atypus

copying src\reportlab\platypus\tableofcontents.py -> build\lib.win32-2.7\reportl
ab\platypus

copying src\reportlab\platypus\tables.py -> build\lib.win32-2.7\reportlab\platyp
us

copying src\reportlab\platypus\xpreformatted.py -> build\lib.win32-2.7\reportlab
\platypus

copying src\reportlab\platypus\__init__.py -> build\lib.win32-2.7\reportlab\plat
ypus

copying src\reportlab\fonts\00readme.txt -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\bitstream-vera-license.txt -> build\lib.win32-2.7\re
portlab\fonts

copying src\reportlab\fonts\DarkGarden-copying-gpl.txt -> build\lib.win32-2.7\re
portlab\fonts

copying src\reportlab\fonts\DarkGarden-copying.txt -> build\lib.win32-2.7\report
lab\fonts

copying src\reportlab\fonts\DarkGarden-readme.txt -> build\lib.win32-2.7\reportl
ab\fonts

copying src\reportlab\fonts\DarkGarden.sfd -> build\lib.win32-2.7\reportlab\font
s

copying src\reportlab\fonts\DarkGardenMK.afm -> build\lib.win32-2.7\reportlab\fo
nts

copying src\reportlab\fonts\DarkGardenMK.pfb -> build\lib.win32-2.7\reportlab\fo
nts

copying src\reportlab\fonts\Vera.ttf -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\VeraBd.ttf -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\VeraBI.ttf -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\VeraIt.ttf -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_abi____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_ab_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_ai_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_a______.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\cobo____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\cob_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\com_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\coo_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_ebi____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_eb_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_ei_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\_er_____.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\Sy______.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\Zd______.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\Zx______.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\fonts\Zy______.pfb -> build\lib.win32-2.7\reportlab\fonts

copying src\reportlab\lib\hyphen.mashed -> build\lib.win32-2.7\reportlab\lib

running build_ext

building '_rl_accel' extension

C:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Pytho
n27\PC -c C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel
.c -o c:\users\jj\documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.o

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c: In fun
ction `hex32':

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c:491: wa
rning: unsigned int format, long unsigned int arg (arg 3)

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c: In fun
ction `_instanceStringWidthU':

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c:741: wa
rning: 'L' might be used uninitialized in this function

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c:741: wa
rning: 't' might be used uninitialized in this function

C:\Users\JJ\Documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.c:741: wa
rning: 'f' might be used uninitialized in this function

writing c:\users\jj\documents\build\reportlab\src\rl_addons\rl_accel\_rl_accel.d
ef

C:\mingw\bin\dllwrap.exe -mno-cygwin -mdll -static --output-lib c:\users\jj\docu
ments\build\reportlab\src\rl_addons\rl_accel\lib_rl_accel.a --def c:\users\jj\do
cuments\build\reportlab\src\rl_addons\rl_accel\_rl_accel.def -s c:\users\jj\docu
ments\build\reportlab\src\rl_addons\rl_accel\_rl_accel.o -LC:\Python27\libs -LC:
\Python27\PCbuild -lpython27 -lmsvcr90 -o build\lib.win32-2.7\_rl_accel.pyd

_rl_accel.exp: file not recognized: File format not recognized

collect2: ld returned 1 exit status

dllwrap: gcc exited with status 1

error: command 'dllwrap' failed with exit status 1

所以,过了一会儿,我偶然发现了一篇到目前为止对我有效的帖子

该站点提供了一个非官方的MinGW-GCC二进制文件(MinGW不支持/支持),旨在与Python完美集成,直至自动更新路径。我安装了它,bam,
pip install cython
刚刚开始工作


希望这对解决gcc问题有更多帮助。

我刚刚回答了同样的问题:为什么dllwrap会在pip中给出这个错误

_foo.exp: file not recognized: File format not recognized
简短回答:检查你的路径。MinGW\bin需要接近其开始位置


详细回答:请参见

我在cygwin中遇到了这个问题,直到我意识到还需要安装gcc-g++包。现在我已经安装了gcc-core和gcc-g++了,
pip-install-pandas
工作起来很有魅力。

看起来(在您尝试cygwin的情况下),gcc二进制文件不在您的路径中。我手头没有windows机器来帮助您解决这个问题,但请尝试重新运行cygwin安装程序并确保安装了gcc。如果是,请将其添加到您的路径中(在Windows中,我认为您可以通过控制面板中的“系统”执行此操作,如果内存没有问题的话)。谢谢,我已经意识到了这一点。我将尝试重新安装cygwin,尽管我确实希望能够从命令提示符下运行pip。不过,我的系统路径中已经有了“C:\mingw\bin”。我有点困惑。我以为明格和西格温是两码事。我认为cygwin有自己的gcc,这与mingw无关。这就解释了为什么即使明戈在场,cygwin也会给出一个错误。我认为,在cygwin安装程序中,您需要仔细查找与gcc相关的选项并启用它。我从未使用过mingw,因此无法对第一个错误进行评论,但majackson对第二个错误的看法似乎是正确的。或者cygwin和mingw合并了什么的?不,你可能是对的;我不知道——因此我提出了这个问题。我不知道cygwin和mingw有不同的GCC。那么您将如何修复它呢?通过重新运行setup.exe并确保从Cygwin中安装gcc。它不是默认安装的。GccWinBinaries不支持。GccWinBinaries支持64位Windows,但不支持64位Python。但使用32位Python,它可以在我的Windows7 64位机器上完美地工作。不过,它不会编译Cython扩展。事实上,更改系统路径并重新启动解决了这个问题。