尝试在Mavericks OS中安装Scrapy时出现以下错误。
我安装了命令行工具和X11我真的不知道发生了什么事,我没有发现浏览网页的同样错误。我认为这可能与Xcode 5.1中的一些变化有关。
感谢您的回答!
这是命令输出的一部分:
$ pip install scrapy
.
.
.
.
Downloading/unpacking cryptography>=0.2.1 (from pyOpenSSL->scrapy)
Downloading cryptography-0.3.tar.gz (208kB): 208kB downloaded
Running setup.py egg_info for package cryptography
OS/X: confusion between 'cc' versus 'gcc' (see issue 123)
will not use '__thread' in the C code
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
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/Users/agonzamart/.virtualenvs/Parser/build/cryptography/setup.py", line 156, in <module>
"test": PyTest,
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/dist.py", line 265, in __init__
self.fetch_build_eggs(attrs.pop('setup_requires'))
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/dist.py", line 289, in fetch_build_eggs
parse_requirements(requires), installer=self.fetch_build_egg
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/pkg_resources.py", line 618, in resolve
dist = best[req.key] = env.best_match(req, self, installer)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/pkg_resources.py", line 862, in best_match
return self.obtain(req, installer) # try and download/install
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/pkg_resources.py", line 874, in obtain
return installer(requirement)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/dist.py", line 339, in fetch_build_egg
return cmd.easy_install(req)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 623, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 653, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 849, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1130, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1118, in run_setup
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: command 'cc' failed with exit status 1
Complete output from command python setup.py egg_info:
OS/X: confusion between 'cc' versus 'gcc' (see issue 123)
will not use '__thread' in the C code
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
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/Users/agonzamart/.virtualenvs/Parser/build/cryptography/setup.py", line 156, in <module>
"test": PyTest,
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/dist.py", line 265, in __init__
self.fetch_build_eggs(attrs.pop('setup_requires'))
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/dist.py", line 289, in fetch_build_eggs
parse_requirements(requires), installer=self.fetch_build_egg
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/pkg_resources.py", line 618, in resolve
dist = best[req.key] = env.best_match(req, self, installer)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/pkg_resources.py", line 862, in best_match
return self.obtain(req, installer) # try and download/install
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/pkg_resources.py", line 874, in obtain
return installer(requirement)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/dist.py", line 339, in fetch_build_egg
return cmd.easy_install(req)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 623, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 653, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 849, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1130, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/Users/agonzamart/.virtualenvs/Parser/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1118, in run_setup
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: command 'cc' failed with exit status 1
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Users/agonzamart/.virtualenvs/Parser/build/cryptography
答案 0 :(得分:23)
这是由于clang
中Xcode 5.1
默认值发生变化而Apple没有注意到它会使用系统Python破坏扩展模块构建。一种解决方法是首先定义以下环境变量:
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
更新[2014-05-16]:正如预期的那样,Apple已经使用OS X 10.9.3
中更新的系统Pythons(2.7,2.6和2.5)解决了这个问题,因此在使用最新的Mavericks时不再需要解决方法和Xcode 5.1+
。但是,截至目前,如果您在OS X 10.8.x
使用Xcode 5.1+
,则{{1}}(Mountain Lion,目前为10.8.5)仍需要解决方法。
答案 1 :(得分:8)
最新版本的clang 升级到错误级别以前曾是警告。要切换回来,您可以在运行安装命令之前直接删除此行为:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install <your package>
这应该有用,但万一出现问题,这里有更多信息:clang error: unknown argument: '-mno-fused-madd' (python package installation failure)
答案 2 :(得分:0)
实际上Ned和Dorian的回答是相互关联的:
我只是花了DAYS在各种软件包中解决这个问题,作为一个Python新手,无法弄清楚这些标志的来源。补充Dorian的答案,Xcode 5只支持Apple的clang编译器而不支持GCC,但是Mavericks附带的Python发行版似乎是用GCC构建的。 _sysconfigdata.py文件包含用于构建Python解释器的标志,这些标志由Python构建系统由各种项目使用。因此,使用Python构建系统的任何项目都使用与已安装的编译器不兼容的标志。
我使用Homebrew安装了python(将它放入/ usr / local / Cellar并在/ usr / local / Cellar中使用了我的apple-gcc42安装),发现安装的_sysconfigdata.py包含合理的标志。但是,它仍在使用GCC。您可能希望使用clang自己从源代码构建Python。我认为编辑_sysconfigdata.py中的标志是避免重复踩到这个问题的最佳方法。
同时删除_sysconfigdata.pyc和_sysconfigdata.pyo。
以下主题还包括这一点:
clang error: unknown argument: '-mno-fused-madd' (python package installation failure) https://discussions.apple.com/thread/5465305