lang错误:未知参数:’-mno-fused-madd’(python软件包安装失败)

2020/10/31 16:22 · python ·  · 0评论

当尝试psycopg2通过Mavericks 10.9上的pip安装时出现以下错误

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已使用更新的系统Python(2.7、2.6和2.5)OS X 10.9.3解决了此问题,因此在使用最新的Mavericks和时不再需要此解决方法Xcode 5.1+但是,到目前为止,OS X 10.8.x如果您正在使用(Mountain Lion,当前为10.8.5),仍需要解决方法Xcode 5.1+

更新:10.9.3解决了系统CPython的问题。

这是由于Apple随Xcode 5.1一起提供的最新clang更新引起的,并且影响了许多人,因此希望可以尽快修复。

更新:没想到会引起如此多的关注,但是这里有更多详细信息:clang 3.4苹果公司正在将默认设置发送给未知标志错误,但是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,以消除系统运行时的此问题。

xCode 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

我用自制软件安装了postgresql,然后想将psycopg2安装到Mavericks上系统提供的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。

为了解决这个问题,基本上我切换了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}

点之后应该可以正常工作。

Amazon Linux [AWS EC2]

试图pip install paramikoAmazon Linux AMI release 2016.09给了我,其中包括一个链接到这个职位的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
本文地址:http://python.askforanswer.com/langcuowuweizhicanshu-mno-fused-maddpythonruanjianbaoanzhuangshibai.html
文章标签: ,   ,   ,  
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!

文件下载

老薛主机终身7折优惠码boke112

上一篇:
下一篇:

评论已关闭!