安装python库时出现“'cc' failed with exit status 1”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22697440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"'cc' failed with exit status 1" error when install python library
提问by Rodolphe
Like many others, I'm having issues installing a python library (downloaded as a tar, then extracted).
像许多其他人一样,我在安装 python 库(作为 tar 下载,然后提取)时遇到问题。
rodolphe-mbp:python-Levenshtein-0.11.2 Rodolphe$ sudo python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to python_Levenshtein.egg-info/requires.txt
writing python_Levenshtein.egg-info/PKG-INFO
writing namespace_packages to python_Levenshtein.egg-info/namespace_packages.txt
writing top-level names to python_Levenshtein.egg-info/top_level.txt
writing dependency_links to python_Levenshtein.egg-info/dependency_links.txt
writing entry points to python_Levenshtein.egg-info/entry_points.txt
reading manifest file 'python_Levenshtein.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*' under directory 'docs'
warning: no previously-included files matching '*pyc' found anywhere in distribution
warning: no previously-included files matching '.project' found anywhere in distribution
warning: no previously-included files matching '.pydevproject' found anywhere in distribution
writing manifest file 'python_Levenshtein.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.9-intel/egg
running install_lib
running build_ext
building 'Levenshtein' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c Levenshtein.c -o build/temp.macosx-10.9-intel-2.7/Levenshtein.o
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1
As suggested elsewhere, I tried entering in terminal "ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future sudo python setup.py install", but no success.
正如其他地方所建议的,我尝试输入终端“ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future sudo python setup.py install”,但没有成功。
Is there a way around this issue that seems to have appeared with xcode 5.1?
有没有办法解决这个似乎在 xcode 5.1 中出现的问题?
采纳答案by Rodolphe
Installing with (inside of the program folder you pulled down)
安装(在您下拉的程序文件夹内)
sudo -E python setup.py install
did the job!
做的工作!
回答by Seth
Run these two lines in your shell before you build:
在构建之前,在 shell 中运行这两行:
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
Those exports tell the compiler to ignore unused arguments rather than complaining about them.
这些导出告诉编译器忽略未使用的参数而不是抱怨它们。
The reason seems to be that Python is compiling modules using the options that it was built with, except one of those options no longer works in mavericks:
原因似乎是 Python 正在使用它构建的选项编译模块,除了这些选项之一不再适用于小牛:
the clang 3.4 Apple is shipping defaults to erroring on unknown flags, but CPython builds modules using the same set of flags it was compiled with originally.
clang 3.4 Apple 将默认设置为在未知标志上出错,但 CPython 使用与最初编译时使用的相同标志集构建模块。
(from: https://stackoverflow.com/a/22315129/65295)
(来自:https: //stackoverflow.com/a/22315129/65295)
Lots of people are running into this:
很多人都遇到过这样的情况:
回答by YPCrumble
For me the issue was that I had just upgraded XCode and needed to install the command line tools (see this answer).
对我来说,问题是我刚刚升级了 XCode 并需要安装命令行工具(请参阅此答案)。
After running xcode-select --installmy python library installed fine.
运行后xcode-select --install我的python库安装得很好。

