clang error: unknown argument: '-mno-fused-madd' (python package installation failure)

后端 未结 14 2355
攒了一身酷
攒了一身酷 2020-11-22 04:43

I get the following error when attempting to install psycopg2 via pip on Mavericks 10.9:

clang: error: unknown argument: \'-mno-fused-madd\' [-W         


        
相关标签:
14条回答
  • 2020-11-22 04:53

    For me, the bad flags were explicitly given in the package's Makefile. So I had to edit the makefile to remove the unrecognized flag from the erroring package.

    0 讨论(0)
  • 2020-11-22 04:57

    Update: 10.9.3 resolves the issue with system CPython.

    This is caused by the latest clang update from Apple that came with Xcode 5.1 today and is affecting many, many people, so hopefully a fix will appear soon.

    Update: Did not expect this to get so much attention, but here's more detail: 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. The system CPython was compiled with several flags that are unknown by clang, thus causing this problem. The following are the current Mavericks (10.9.2) CPython compile flags:

    -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -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
    

    To resolve this issue you have a few options:

    • Add ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future to your compile flags.
    • Pass CFLAGS=""
    • Strip the unsupported flags from the sysconfigdata.py (as is noted in another answer).
    • Compile a new python using homebrew.
    • Wait for the next OS X update, which is rumored to include recompiled Python/Ruby to remove this issue for system runtimes.
    0 讨论(0)
  • 2020-11-22 05:00

    Upgrading Homebrew and installing unixodbc solved it for me

    brew upgrade
    brew install unixodbc
    
    0 讨论(0)
  • 2020-11-22 05:01

    You're probably on Python 2.7.5

    $ python
    
    Python 2.7.5 (default, Aug 25 2013, 00:04:04)  [GCC 4.2.1 Compatible
    Apple LLVM 5.0 (clang-500.0.68)] on darwin
    

    Easiest solution go to www.python.org and install Python 2.7.6 which is compatible with the LLVM 5.1.

    Then toast your old virtual environment, rmvirtualenv {virtual_env_name}.

    Then make a new virtual env..

    mkvirtualenv --no-site-packages -p/Library/Frameworks/Python.framework/Versions/2.7/bin/python {virtual_env_name}
    

    pip should work fine after this.

    0 讨论(0)
  • 2020-11-22 05:05

    You can tell clang to not raise this as an error by setting the following environment variables prior compilation:

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

    Then pip install psycopg2should work.

    I had the same when trying to pip install lxml.

    Edit: if you are installing as superuser (which will likely be the case if you are trying to append to /Library/Python/2.7/site-packages, the native Apple factory-installed Python distribution which ships with OS X, rather than to some other Python distribution which you have subsequently installed yourself), then you will need to do, as described by @Thijs Kuipers in comments below:

    sudo -E pip install psycopg2
    

    or the equivalent, for whatever other package name you may be substituting in place of psycopg2.

    UPDATE [2014-05-16]: Apple has fixed this problem with updated system Pythons (2.7, 2.6, and 2.5) in OS X 10.9.3 so the workaround is no longer necessary when using the latest Mavericks and Xcode 5.1+. However, as of now, the workaround is still required for OS X 10.8.x (Mountain Lion, currently 10.8.5) if you are using Xcode 5.1+ there.

    0 讨论(0)
  • 2020-11-22 05:05

    Here is a work around that involves removing the flag from the python installation.

    In /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py are several places where the -mfused-madd / -mno-fused-madd flag is set.

    Edit this file and remove all of the references to that flag your compilation should work:

    sudo sed -i '.old' 's/ -m\(no-\)\{0,1\}fused-madd //g' /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py
    

    You need to delete the corresponding _sysconfigdata.pyc and _sysconfigdata.pyo files as well - at least on my system these files did not automatically get rebuilt:

    cd /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
    sudo rm _sysconfigdata.pyo _sysconfigdata.pyc
    

    Note that have to use root access to make those changes.

    0 讨论(0)
提交回复
热议问题