gpt4 book ai didi

python - 在 Mac OS X 10.8.1 上安装 lxml 时我做错了什么?

转载 作者:太空狗 更新时间:2023-10-29 20:40:59 52 4
gpt4 key购买 nike

我在 Mac OS X 10.8.1 和 Python 2.7.2 上构建 lxml 时遇到问题。 (我已经克隆了 Github 存储库并按照此处针对 Mac OS X 的说明进行操作:http://lxml.de/build.html)

在构建 libxml2 时似乎有问题;以下是终端输出的尾端:

configure: creating ./config.status
config.status: creating libxml2.spec
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating include/libxml/Makefile
config.status: creating doc/Makefile
config.status: creating doc/examples/Makefile
config.status: creating doc/devhelp/Makefile
config.status: creating example/Makefile
config.status: creating python/Makefile
config.status: creating python/tests/Makefile
config.status: creating xstc/Makefile
config.status: creating include/libxml/xmlversion.h
config.status: creating xml2-config
config.status: creating libxml-2.0.pc
config.status: creating libxml-2.0-uninstalled.pc
config.status: creating python/setup.py
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
rm: libtoolT: No such file or directory
Done configuring
make all-recursive
Making all in include
Making all in libxml
make[3]: Nothing to be done for `all'.
make[3]: Nothing to be done for `all-am'.
Making all in .
CC error.lo

[剪断]

  CC     hash.lo
parser.c: In function 'xmlParseInNodeContext':
parser.c:13492: warning: pointer targets in passing argument 1 of 'xmlFindCharEncodingHandler' differ in signedness
CC list.lo

[剪断]

  CC     xpointer.lo
xpath.c: In function 'xmlXPathRegisterFuncNS':
xpath.c:4870: warning: ISO C forbids passing argument 4 of 'xmlHashAddEntry2' between function pointer and 'void *'
xpath.c: In function 'xmlXPathFunctionLookupNS':
xpath.c:4951: warning: ISO C forbids assignment between function pointer and 'void *'
xpath.c: In function 'xmlXPathCompOpEval':
xpath.c:13535: warning: ISO C forbids assignment between function pointer and 'void *'
xpath.c:13562: warning: ISO C forbids assignment between function pointer and 'void *'
xpath.c: At top level:
trionan.c:221: warning: 'trio_is_negative' defined but not used
CC xinclude.lo

[剪断]

  CC     xmlstring.lo
threads.c: In function 'xmlCleanupThreads':
threads.c:918: error: expected expression before '{' token
make[2]: *** [threads.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Traceback (most recent call last):
File "setup.py", line 225, in <module>
**setup_extra_options()
File "setup.py", line 139, in setup_extra_options
STATIC_CFLAGS, STATIC_BINARIES)
File "/Users/jedc/Downloads/lxml/setupinfo.py", line 57, in ext_modules
multicore=OPTION_MULTICORE)
File "/Users/jedc/Downloads/lxml/buildlibxml.py", line 338, in build_libxml2xslt
cmmi(libxml2_configure_cmd, libxml2_dir, multicore, **call_setup)
File "/Users/jedc/Downloads/lxml/buildlibxml.py", line 266, in cmmi
cwd=build_dir, **call_setup)
File "/Users/jedc/Downloads/lxml/buildlibxml.py", line 249, in call_subprocess
raise Exception('Command "%s" returned code %s' % (cmd_desc, returncode))
Exception: Command "make -j5" returned code 512

我试图弄清楚这里出了什么问题,这超出了我的深度。 任何人都可以指出我需要做些什么来解决这个问题吗?

最佳答案

这是 libxml2 2.9 中的错误。

你得到的错误是在这一行:

once_control = PTHREAD_ONCE_INIT;

那是非法代码,恰好可以在 Linux 上运行。 PTHREAD_ONCE_INIT 只能用于初始化,不能用于赋值,这是有特定原因的:因此平台可以将 PTHREAD_ONCE_INIT 定义为聚合初始化器。哪个 OS X 呢。来自 10.8.1 的 /usr/include/pthread.h:

#define PTHREAD_ONCE_INIT {_PTHREAD_ONCE_SIG_init, {0}}

看起来这已经在几天前报告给 libxml2 邮件列表 (https://mail.gnome.org/archives/xml/2012-September/msg00036.html),两天后提交到 bugzilla ( https://bugzilla.gnome.org/show_bug.cgi?id=684024),并在第二天修复 (http://git.gnome.org/browse/libxml2/commit/?id=3f6cfbd1d38d0634a2ddcb9a0a13e1b5a2195a5e),所以大概是 2.9 .1不会有这个问题。

所以,这是您的选择:

当然可以等2.9.1出来

或者,不管构建页面怎么说,Mountain Lion 附带的 libxml2 版本 2.7.8 并不是“非常过时”——它比他建议使用的 2.7.3 版本更新。因此,您可以跳过 --static-deps 并使用内置的 2.7.8。

如果你确实想要比 2.7.8 更新的东西,但不像(非工作的)2.9.0 一样新,构建页面显示了如何明确指定它,并且 http://www.xmlsoft.org应该在某个地方有版本历史,这样你就可以选择你想要的版本。例如:

python setup.py build --static-deps \
--libxml2-version=2.8.0

或者您可以手动应用来自 http://git.gnome.org/browse/libxml2/commit/?id=3f6cfbd1d38d0634a2ddcb9a0a13e1b5a2195a5e 的补丁并手动构建它,或者拉出树的顶部而不是版本 2.9.0,构建它,然后告诉 lxml 使用该构建。

将来,如果您不想处理调试构建,我建议您只使用 pip 安装 Python 包,并使用 Homebrew 安装任何缺少的依赖项。您可能并不总能获得最新版本的理想构建,但它会容易得多,而且通常也足够好。

关于python - 在 Mac OS X 10.8.1 上安装 lxml 时我做错了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12484664/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com