簡體   English   中英

clang 錯誤:未知參數:'-mno-fused-madd'(python 包安裝失敗)

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

嘗試在 Mavericks 10.9 上通過 pip 安裝psycopg2時出現以下錯誤:

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

不確定如何繼續,並已在此處和其他地方搜索此特定錯誤。 任何幫助深表感謝!

這是 pip 的完整輸出:

$ pip install psycopg2
Downloading/unpacking psycopg2
  Downloading psycopg2-2.5.2.tar.gz (685kB): 685kB downloaded
  Running setup.py (path:/private/var/folders/0z/ljjwsjmn4v9_zwm81vhxj69m0000gn/T/pip_build_tino/psycopg2/setup.py) egg_info for package psycopg2

Installing collected packages: psycopg2
  Running setup.py install for psycopg2
    building 'psycopg2._psycopg' 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 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.5.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090303 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.3.3/include -I/usr/local/Cellar/postgresql/9.3.3/include/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.9-intel-2.7/psycopg/psycopgmodule.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
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/0z/ljjwsjmn4v9_zwm81vhxj69m0000gn/T/pip_build_tino/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/0z/ljjwsjmn4v9_zwm81vhxj69m0000gn/T/pip-bnWiwB-record/install-record.txt --single-version-externally-managed --compile:
    running install

running build

running build_py

creating build

creating build/lib.macosx-10.9-intel-2.7

creating build/lib.macosx-10.9-intel-2.7/psycopg2

copying lib/__init__.py -> build/lib.macosx-10.9-intel-2.7/psycopg2

copying lib/_json.py -> build/lib.macosx-10.9-intel-2.7/psycopg2

copying lib/_range.py -> build/lib.macosx-10.9-intel-2.7/psycopg2

copying lib/errorcodes.py -> build/lib.macosx-10.9-intel-2.7/psycopg2

copying lib/extensions.py -> build/lib.macosx-10.9-intel-2.7/psycopg2

copying lib/extras.py -> build/lib.macosx-10.9-intel-2.7/psycopg2

copying lib/pool.py -> build/lib.macosx-10.9-intel-2.7/psycopg2

copying lib/psycopg1.py -> build/lib.macosx-10.9-intel-2.7/psycopg2

copying lib/tz.py -> build/lib.macosx-10.9-intel-2.7/psycopg2

creating build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/__init__.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/dbapi20.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/dbapi20_tpc.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_async.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_bug_gc.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_bugX000.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_cancel.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_connection.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_copy.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_cursor.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_dates.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_extras_dictcursor.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_green.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_lobject.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_module.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_notify.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_psycopg2_dbapi20.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_quote.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_transaction.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_types_basic.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_types_extras.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/test_with.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/testconfig.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

copying tests/testutils.py -> build/lib.macosx-10.9-intel-2.7/psycopg2/tests

running build_ext

building 'psycopg2._psycopg' extension

creating build/temp.macosx-10.9-intel-2.7

creating build/temp.macosx-10.9-intel-2.7/psycopg

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 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.5.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090303 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.3.3/include -I/usr/local/Cellar/postgresql/9.3.3/include/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.9-intel-2.7/psycopg/psycopgmodule.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

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/0z/ljjwsjmn4v9_zwm81vhxj69m0000gn/T/pip_build_tino/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/0z/ljjwsjmn4v9_zwm81vhxj69m0000gn/T/pip-bnWiwB-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/0z/ljjwsjmn4v9_zwm81vhxj69m0000gn/T/pip_build_tino/psycopg2

您可以通過在編譯之前設置以下環境變量來告訴 clang 不要將此作為錯誤引發:

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

然后pip install psycopg2應該可以工作。

嘗試pip install lxml時我也有同樣的情況。

編輯:如果您以超級用戶身份安裝(如果您嘗試附加到/Library/Python/2.7/site-packages ,則可能是這種情況,即 OS X 附帶的原生 Apple 工廠安裝的 Python 發行版,而不是附加到您隨后自己安裝了一些其他 Python 發行版),那么您將需要這樣做,如@Thijs Kuipers 在下面的評論中所述:

sudo -E pip install psycopg2

或等效的,對於您可能替換為psycopg2任何其他包名稱。

更新 [2014-05-16]:Apple 已在OS X 10.9.3使用更新的系統 Python( Xcode 5.1+和 2.5)修復了此問題,因此在使用最新的 Mavericks 和Xcode 5.1+時不再需要解決方法。 但是,到目前為止,如果您在那里使用Xcode 5.1+OS X 10.8.x (Mountain Lion,目前為 10.8.5)仍然需要解決方法。

更新:10.9.3 解決了系統 CPython 的問題。

這是由今天 Xcode 5.1 附帶的 Apple 最新的 clang 更新引起的,並且影響了很多很多人,因此希望很快就會出現修復程序。

更新:沒想到這會引起如此多的關注,但這里有更多細節:clang 3.4 Apple 正在發布默認為在未知標志上出錯,但 CPython 使用與最初編譯時使用的相同標志集構建模塊。 系統CPython編譯了幾個clang未知的標志,從而導致了這個問題。 以下是當前的 Mavericks (10.9.2) CPython 編譯標志:

-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

要解決此問題,您有幾個選擇:

  • ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future到您的編譯標志中。
  • 通過CFLAGS=""
  • 從 sysconfigdata.py 中刪除不受支持的標志(如另一個答案中所述)。
  • 使用homebrew編譯一個新的 python。
  • 等待下一個 OS X 更新,據傳它包含重新編譯的 Python/Ruby,以消除系統運行時的這個問題。

代碼 5.1

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install psycopg2

這是一個解決方法,涉及從 python 安裝中刪除標志。

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py有幾個設置-mfused-madd / -mno-fused-madd標志的地方。

編輯此文件並刪除對該標志的所有引用,您的編譯應該可以工作:

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

您還需要刪除相應的_sysconfigdata.pyc_sysconfigdata.pyo文件 - 至少在我的系統上,這些文件沒有自動重建:

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

請注意,必須使用 root 訪問權限才能進行這些更改。

我還編輯了系統 python 對其原始編譯標志的概念(如@user3405479 所做的那樣)。 我沒有使用編輯器,而是使用命令行工具“就地”編輯文件(inode 確實發生了變化)。 我還編譯了新的 pyo 和 pyc 文件,而不是將它們刪除。

以下命令以 root 身份運行,例如在sudo -i

pushd /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7

sed 's/-mno-fused-madd//g' _sysconfigdata.py \\ | diff -p _sysconfigdata.py - | patch -b

python -m py_compile _sysconfigdata.py

python -OO -m py_compile _sysconfigdata.py

popd

我用homebrew安裝了postgresql,然后想把psycopg2安裝到系統自帶的python 2.7上小牛。 為了讓它工作,我最終運行了這個:

sudo ARCHFLAGS="-arch x86_64" CFLAGS=-Wunused-command-line-argument-hard-error-in-future pip install psycopg2

至少 Apple 意識到了這一點,因為在 Xcode 5.1 發行說明(編譯器部分)中討論了這個問題。 期待在下一次操作系統更新中更新 Python 和 Ruby(手指交叉!)。 另請注意, -Wno-error=unused-command-line-argument-hard-error-in-future標志是一種臨時解決方法,將來會消失(希望在系統 Python 修復后!)。

如果您是像我一樣的 Python 包維護者,並希望為您的用戶省去自己解決這個問題的麻煩,這里有一個解決方案(除了提供二進制輪子/雞蛋),它會進入您的setup.py文件:

from distutils.command.build_ext import build_ext
import subprocess
import sys

# Workaround for OS X 10.9.2 and Xcode 5.1+
# The latest clang treats unrecognized command-line options as errors and the
# Python CFLAGS variable contains unrecognized ones (e.g. -mno-fused-madd).
# See Xcode 5.1 Release Notes (Compiler section) and
# http://stackoverflow.com/questions/22313407 for more details. This workaround
# follows the approach suggested in http://stackoverflow.com/questions/724664.
class build_ext_subclass(build_ext):
    def build_extensions(self):
        if sys.platform == 'darwin':
            # Test the compiler that will actually be used to see if it likes flags
            proc = subprocess.Popen(self.compiler.compiler + ['-v'],
                                    stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                                    universal_newlines=True)
            stdout, stderr = proc.communicate()
            clang_mesg = "clang: error: unknown argument: '-mno-fused-madd'"
            if proc.returncode and stderr.splitlines()[0].startswith(clang_mesg):
                for ext in self.extensions:
                    # Use temporary workaround to ignore invalid compiler option
                    # Hopefully -mno-fused-madd goes away before this workaround!
                    ext.extra_compile_args += ['-Wno-error=unused-command-line-argument-hard-error-in-future']
        build_ext.build_extensions(self)

setup(
    name="mypackage",
    ...
    cmdclass={'build_ext' : build_ext_subclass},
    ...
)

以上解決方案都不適合我。 我的情況略有不同。 當我收到此錯誤消息時,我試圖通過自制軟件安裝 rdiff-backup。

我顯然有 Apple 的默認 python (2.7.5 @ /usr/bin/python) 和 Homebrew 的 python (2.7.6 @ /usr/local/Cellar/python/2.7.6/bin/python),但錯誤來了來自蘋果的蟒蛇。

為了解決這個問題,基本上我切換了 python 二進制文件。

我是通過 sudo 做到的:

  • cp /usr/bin/python /usr/bin/python_orig
  • ln -s /usr/local/Cellar/python/2.7.6/bin/python /usr/bin/python

然后,'brew install rdiff-backup' 成功而沒有任何錯誤。

最后,我做了“mv /usr/bin/python_orig /usr/bin/python”來恢復一切。

您可能使用的是 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

最簡單的解決方案是訪問 www.python.org 並安裝與 LLVM 5.1 兼容的 Python 2.7.6。

然后敬酒您的舊虛擬環境rmvirtualenv {virtual_env_name}

然后創建一個新的虛擬環境..

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

在此之后 pip 應該可以正常工作。

亞馬遜 Linux [AWS EC2]

嘗試在Amazon Linux AMI release 2016.09 pip install paramikopip install paramiko給了我一個錯誤,其中包含指向此 SO 帖子的鏈接。 因此,即使它不符合 OP 的標題,我還是要分享答案。

yum install libffi-devel
yum install gcc
yum install openssl-devel
pip install paramiko

我使用自制的python包。 重新編譯后運行良好。

_sysconfigdata.py 修復的變化:使用虛擬環境

cp /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py ${VIRTUAL_ENV}/lib/python2.7/_sysconfigdata.py

然后在 ${VIRTUAL_ENV}/lib/python2.7/_sysconfigdata.py 編輯您的副本

我刪除了'-mno-fused-madd'的所有出現,然后在那個virtualenv中構建工作。

無需root!

對我來說,包的 Makefile 中明確給出了壞標志。 所以我不得不編輯 makefile 以從錯誤包中刪除無法識別的標志。

升級 Homebrew 並安裝 unixodbc 為我解決了這個問題

brew upgrade
brew install unixodbc

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM