【问题标题】:clang error when installing pygresql under Mac OSMac OS下安装pygresql时出现clang错误
【发布时间】:2016-06-04 07:27:20
【问题描述】:

我试图在 Mac OS X(10.11.3) 下安装 PyGreSQL,但是从 pip 和 source 安装时出现同样的 clang 错误。

$ python3 setup.py install
running install
running bdist_egg
running egg_info
writing PyGreSQL.egg-info/PKG-INFO
writing top-level names to PyGreSQL.egg-info/top_level.txt
writing dependency_links to PyGreSQL.egg-info/dependency_links.txt
reading manifest file 'PyGreSQL.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'PyGreSQL.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-intel/egg
running install_lib
running build_py
running build_ext
building '_pg' extension
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -DPYGRESQL_VERSION=5.0 -DDIRECT_ACCESS -DLARGE_OBJECTS -DDEFAULT_VARS -DESCAPING_FUNCS -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -I/Library/PostgreSQL/9.5/include -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c pgmodule.c -o build/temp.macosx-10.6-intel-3.5/pgmodule.o -O2 -funsigned-char -Wall -Werror
pgmodule.c:3684:3: error: code will never be executed [-Werror,-Wunreachable-code]
                long    num_rows;
                ^~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

clang error occurs when installing PyGreSQL

我的机器上已经安装了 PyGreSQL、Xcode 和 Xcode 工具,并且我还将 PostgreSQL 的 bin 目录添加到了 $PATH。

【问题讨论】:

    标签: python postgresql clang pygresql


    【解决方案1】:

    我能够通过编辑模块的 setup.py

    来编译模块

    找线

    extra_compile_args = ....
    

    这是传递给 clang 的额外编译参数列表。额外的参数之一将是 -Werror,这意味着“将所有警告视为错误”。如您所知,错误将中止编译。

    删除该行,然后再次运行python3 setup.py build,您会看到出现相同的行,但这次是警告,一切正常!

    【讨论】:

    • 这应该可以解决问题。它将在高于 5.0.3 的 PyGreSQL 版本中修复(请参阅github.com/Cito/pygresql/issues/4)。
    • @Cito 不是:-Werror 还在那里,人们 stumble 在上面。 :-(
    • @Phd 感谢您的通知。 MacOS 下的实际问题实际上是solved。 -Werror 标志并没有被故意删除——我们希望出现错误,以便我们可以调查并修复根本原因。在这种情况下,它看起来像是 CentOS 上的另一个错误,我们需要进行调查。我现在订阅了 pygresql 标签,以防人们只在这里报告而不是使用我们的邮件列表或错误跟踪器。
    猜你喜欢
    • 2013-01-02
    • 1970-01-01
    • 1970-01-01
    • 2021-11-08
    • 2011-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多