【问题标题】:clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]clang:错误:未知参数:'-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
【发布时间】:2014-05-07 08:35:12
【问题描述】:

尝试在 Mavericks 操作系统中安装 Scrapy 时出现以下错误。

我安装了命令行工具并安装了 X11 我真的不知道发生了什么,我在浏览 Web 时没有发现同样的错误。我认为这可能与 Xcode 5.1 的一些变化有关

感谢您的回答!

这是命令输出的一部分:

$pip 安装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

【问题讨论】:

    标签: python scrapy pip x11 xcode5.1


    【解决方案1】:

    这是因为 Xcode 5.1 中的 clang 默认值发生了变化,并且 Apple 没有注意到它会破坏使用系统 Python 构建的扩展模块。一种解决方法是先定义以下环境变量:

    export CFLAGS=-Qunused-arguments
    export CPPFLAGS=-Qunused-arguments
    

    更新 [2014-05-16]:正如预期的那样,Apple 已通过 OS X 10.9.3 中更新的系统 Python(2.7、2.6 和 2.5)修复了此问题,因此在使用最新的 Mavericks 和 @ 987654325@。但是,到目前为止,如果您在那里使用Xcode 5.1+OS X 10.8.x(Mountain Lion,当前为 10.8.5)仍然需要解决方法。

    【讨论】:

    • 谢谢内德。这似乎不起作用。我将变量添加到我的 .bash_profile 但我仍然得到同样的错误。
    • 你在使用 sudo 吗?如果是这样,环境变量设置可能不会被复制到 sudo 环境中。尝试sudo bash,然后输入export 语句,然后输入pippython 命令进行安装。
    • 谢谢 Ned,现在看来可以了!您能否解释或将我链接到为什么导出这些标志使其工作的地方?非常感谢!!
    • 从 OS X 10.8 (IIRC) 开始,Apple 从使用 gcc 切换到 clang 来构建 OS X 本身,包括系统 Python。但是他们忘记在构建脚本中删除一些仅 gcc 的选项。这并没有造成问题,因为 clang 忽略了它们。随着 Xcode 5.1 的引入,clang 被更改为如果使用任何未知参数调用它会导致错误。这不会影响 OS X 10.9 的现有编译位。但是,当您要求 Python 构建 C 扩展模块时,它会尝试使用与构建 Python 本身时相同的编译器选项。在 5.1 中,这些选项不再起作用。
    • 因此,我们可以希望 Apple 能够在更新到 10.9 时解决该问题(他们有多种简单的方法可以做到这一点)。当所有的 Python 都需要重建时,它肯定会在 OS X(10.10?)的下一个版本中得到修复。
    【解决方案2】:

    最新版本的 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)

    【讨论】:

    • 谢谢。另一个解决方案对我不起作用,但这个解决方案有效。非常感谢:)
    • 很高兴我能帮上忙 :)
    猜你喜欢
    • 2014-11-24
    • 2014-05-26
    • 2014-10-24
    • 2014-06-02
    • 1970-01-01
    • 1970-01-01
    • 2014-04-18
    • 2014-04-14
    相关资源
    最近更新 更多