在Mac OS X 10.8.1上安装lxml时,我做错了什么?(What am I doing wrong when installing lxml on Mac OS X 10.8.1?)

编程入门 行业动态 更新时间:2024-10-23 18:29:15
在Mac OS X 10.8.1上安装lxml时,我做错了什么?(What am I doing wrong when installing lxml on Mac OS X 10.8.1?)

我在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

在我的深度之外,我试图找出这里有什么问题。 任何人都可以指出我需要做什么来解决这个问题?

I'm building lxml on Mac OS X 10.8.1 and Python 2.7.2 and having problems. (I've cloned the Github repository and followed the instructions for Mac OS X here: http://lxml.de/build.html)

It appears something hangs in building libxml2; the following is the tail end of the terminal output:

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

[snipped]

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

[snipped]

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

[snipped]

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

I'm WAY outside my depth in trying to figure out what's wrong here. Can anyone point me in the direction of what I need to do to fix this?

最满意答案

这是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出来。

另外,尽管构建页面说了什么,但2.7.8版本的Mountain Lion提供的libxml2版本并不是“过时的”,这比他建议使用的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可以安装任何缺少的依赖项。 你可能并不总是获得最新版本的理想版本,但它会更容易,通常也足够好。

This is a bug in libxml2 2.9.

The error you're getting is on this line:

once_control = PTHREAD_ONCE_INIT;

That's illegal code, that just happens to work on linux. PTHREAD_ONCE_INIT can only be used for initialization, not assignment, and there's a specific reason for that: so platforms can define PTHREAD_ONCE_INIT as an aggregate initializer. Which OS X does. From 10.8.1's /usr/include/pthread.h:

#define PTHREAD_ONCE_INIT {_PTHREAD_ONCE_SIG_init, {0}}

It looks like this has been reported to the libxml2 mailing list a few days ago (https://mail.gnome.org/archives/xml/2012-September/msg00036.html), filed in bugzilla two days later (https://bugzilla.gnome.org/show_bug.cgi?id=684024), and fixed the next day (http://git.gnome.org/browse/libxml2/commit/?id=3f6cfbd1d38d0634a2ddcb9a0a13e1b5a2195a5e), so presumably 2.9.1 will not have this problem.

So, here are your options:

Of course you could wait for 2.9.1 to come out.

Alternative, despite what the build page says, the version of libxml2 that comes with Mountain Lion, 2.7.8, is not "horribly outdated"—it's newer than the 2.7.3 version he suggests using. So, you can just skip the --static-deps and use the built-in 2.7.8.

If you do want something newer than 2.7.8, but not as new as the (non-working) 2.9.0, the build page shows how to specify it explicitly, and http://www.xmlsoft.org should have the version history somewhere so you can pick the version you want. For example:

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

Or you could manually apply the patch from http://git.gnome.org/browse/libxml2/commit/?id=3f6cfbd1d38d0634a2ddcb9a0a13e1b5a2195a5e and build that manually, or pull the top of tree instead of version 2.9.0, build that, and then tell lxml to use that build.

In the future, if you don't want to have to deal with debugging builds, I'd suggest just using pip to install Python packages, and Homebrew to install any missing dependencies. You may not always get the ideal build of the very latest version of everything, but it will be a lot easier, and usually good enough.

更多推荐

本文发布于:2023-07-22 18:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1222320.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错了   我做   OS   Mac   installing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!