(仍然)无法正确安装 python 的 lxml 2.3,但至少 2.2.8 可以工作
2011 年 6 月 30 日——我将这个问题授予@Pablo,因为他的答案。 由于他的评论中讨论的原因,我仍然无法正确安装 lxml 2.3。我收集了一些可以做的工作,但我已经在这个问题上花费了大量的时间。不过,我已经编写了所需的代码并成功安装了 lxml 2.2.8。该代码可在该版本中运行。更好的是,巴勃罗是唯一正确诊断出错误的人。 libxslt 需要更新到支持
exsltMathXpathCtxtRegister
的版本,感谢大家对这个问题的帮助。2011年6月29日 - 更新此问题以反映评论并更好地记录我的尝试
首先我应该说我已经尝试了所有可能的解决方案并安装了可以想象的场景。是的,这个主题也有类似的问题,但他们的具体问题和解决方案不是我自己的。我在这个问题上花了大约 10-15 个小时,但我却变得更加困惑。
我主要关心的问题
简而言之,在centOs5.6上使用easy_install-2.7 lxml
从源或安装lxml-2.3 for python2.7后,替代安装 python,我无法正确导入模块。它将安装而不会出现任何明显的错误,但在尝试导入 etree 时会返回以下错误:
Python 2.7.2 (default, Jun 16 2011, 11:53:48)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> from lxml import etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/local/lib/python2.7/site-packages/lxml-2.3-py2.7-linux-x86_64.egg/lxml/etree.so: undefined symbol: exsltMathXpathCtxtRegister
我尝试过的内容
我遇到的两个最常见的建议是确保
libxml2 && libxml2-dev
和libxslt1 && libxslt1-dev 是的。我已经通过 yum 安装了它们。
<块引用> $ yum list libxslt libxslt-devel libxml2 libxml2-devel 加载的插件: fastmirror 安装的软件包 libxml2.i386
2.6.26-2.1.2.8.el5_5.1安装libxml2.x86_64
2.6.26-2.1.2.8.el5_5.1安装libxml2-devel.i386
2.6.26-2.1.2.8.el5_5.1安装了libxml2-devel.x86_64
2.6.26-2.1.2.8.el5_5.1安装libxslt.i386
1.1.17-2.el5_2.2安装libxslt.x86_64
1.1.17-2.el5_2.2安装libxslt-devel.i386
1.1.17-2.el5_2.2安装libxslt-devel.x86_64
1.1.17-2.el5_2.2已安装重新安装并确认
zlib && zlib-devel 已安装。
<块引用>
$ yum list zlib zlib-devel 已加载 插件:fastestmirror 已安装 软件包 zlib.i386
1.2.3-3安装zlib.x86_64
1.2.3-3安装zlib-devel.i386
1.2.3-3安装zlib-devel.x86_64
1.2.3-3已安装确认
python-devel
已安装。我认为。a.根据我读到的几件事,检查 python-devel 是否安装的方法是导入 distutils。重新搜索这个问题可以快速这个。
b. @Keith 建议我尝试使用 这个,但是,我遇到了错误
<前><代码>>错误:无法创建 %sourcedir /usr/src/redhat/SOURCES所以,我创建了该目录,并且它已经安装了。但没有成功。
但是,我可以
导入 xml.etree.cElementTree as etree
和/或导入 xml.etree.ElementTree as etree
,但我确实需要一些特定功能lxml.etree
奇怪的是,如果我尝试在假设未安装依赖项的情况下安装 lxml 并尝试类似以下内容
sudo STATIC_DEPS=true easy_install-2.7 lxml 2>&1 | tee -a ~/.lxml
它失败并输出以下错误。我应该简洁地指出,对于不熟悉的人来说,这似乎解决了很多人的问题,因为它将出去并检索所有依赖项并安装它们以安装 lxml。
<块引用>tail -100 ~/.lxml
gcc -DHAVE_CONFIG_H -I。 -I./包括 -I./include -D_REENTRANT -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate -return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c runsuite.c gcc -DHAVE_CONFIG_H -I。 -I./include -I./include -D_REENTRANT -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate -return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c testchar.c testapi.c:在函数中 'test_xmlBufferSetAllocationScheme': testapi.c:18773:警告:比较 不同的指针类型缺少强制转换 gcc -DHAVE_CONFIG_H -I。 -I./包括 -I./include -D_REENTRANT -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate -return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c testdict.c gcc -DHAVE_CONFIG_H -I。 -I./include -I./include -D_REENTRANT -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate -return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c runxmlconf.c gcc -DHAVE_CONFIG_H -I。 -I./include -I./include -D_REENTRANT -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate -return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c testrecurse.c sed -e 的?\@XML_LIBDIR\@?-L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib?g' \ -e 's?\@XML_INCLUDEDIR\@?-I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include/libxml2 -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/ libxml2/include?g' \ -e 's?\@VERSION\@?2.7.8?g' \ -e 's?\@XML_LIBS\@?-lxml2 -lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm ?g' \ < ./xml2Conf.sh.in> xml2Conf.tmp \ && mv xml2Conf.tmp xml2Conf.sh /bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -module -no-undefined -avoid-version -rpath /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -o testdso.la testdso.lo testapi。 c:在顶层:testapi.c:17989: 警告:“gen_xmlSchematronPtr” 已定义但未使用 testapi.c:17992: 警告:“des_xmlSchematronPtr” 已定义但未使用 testapi.c:18009: 警告: 'gen_xmlSchematronParserCtxtPtr' 已定义但未使用 testapi.c:18012: 警告: 'des_xmlSchematronParserCtxtPtr' 已定义但未使用 testapi.c:34157: 警告:'gen_xmlSAXHandlerPtr_ptr' 已定义但未使用 testapi.c:34160: 警告:“des_xmlSAXHandlerPtr_ptr” 已定义但未使用 libtool: 链接: ar cru.libs/testdso.a testdso.o libtool:链接:ranlib .libs/testdso.a libtool: 链接: ( cd ".libs" && rm -f “testdso.la”&& ln -s“../testdso.la” “testdso.la”)/bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer- arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -版本信息 9:8:7 -ldl -o libxml2.la -rpath /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib SAX.loEntity.loencoding.lo error.lo parserInternals.lo parser.lo 树.lo 散列.lo 列表.lo xmlIO.lo xmlmemory.lo uri.lo valid.lo xlink.lo HTMLparser.lo HTMLtree.lo debugXML.lo xpath.lo xpointer.lo xinclude.lo nanohttp.lo nanoftp.lo DOCBparser.lo 目录.lo 全局.lo 线程.lo c14n.lo xmlstring.lo xmlregexp.lo xmlschemas.lo xmlschemastypes.lo xmlunicode.lo xmlreader.lo Relaxng.lo dict.lo SAX2.lo xmlwriter.lo Legacy.lo chvalid.lopattern.loxmlsave.lo xmlmodule.lo schematron.lo -lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm libtool:链接:ar cru .libs/libxml2.a SAX.oEntity.o 编码.o 错误.o 解析器内部.o parser.o tree.o hash.o list.o xmlIO.o xmlmemory.o uri.o valid.o xlink.o HTMLparser.o HTMLtree.o debugXML.o xpath.o xpointer.o xinclude.o nanohttp.o nanoftp.o DOCBparser.o 目录.o 全局.o 线程.o c14n.o xmlstring.o xmlregexp.o xmlschemas.o xmlschemastypes.o xmlunicode.o xmlreader.o Relaxng.o dict.o SAX2.o xmlwriter.o Legacy.o chvalid.o 模式.o xmlsave.o xmlmodule.o schematron.o libtool:链接:ranlib .libs/libxml2.a libtool: 链接: ( cd “.libs”&& rm -f "libxml2.la" && ln-s “../libxml2.la”“libxml2.la”)/bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate -return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o xmllint xmllint.o ./libxml2.la -lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm /bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o xmlcatalog xmlcatalog.o ./libxml2.la -lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm /bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testSchemas testSchemas.o ./libxml2.la -lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm /bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testRelax testRelax.o ./libxml2.la -lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm /bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testSAX testSAX.o ./libxml2.la - lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm libtool:链接:gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch - Wcomment -Wtrigraphs -Wformat -Wchar-下标 -Wuninitialized -W括号 -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testSAX testSAX.o ./.libs/libxml2.a -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -ldl -lz /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib/libiconv.a -lm libtool:链接:gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-对齐-Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testRelax testRelax.o ./.libs/libxml2.a -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -ldl -lz /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib/libiconv.a -lm libtool:链接:gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-对齐-Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o xmlcatalog xmlcatalog.o ./.libs/libxml2.a -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -ldl -lz /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib/libiconv.a -lm libtool:链接:gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-对齐-Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testSchemas testSchemas.o ./.libs/libxml2.a -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -ldl -lz /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib/libiconv.a -lm libtool:链接:gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-对齐-Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o xmllint xmllint.o ./.libs/libxml2.a -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -ldl -lz /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib/libiconv.a -lm ./..libs/libxml2.a(/.xmlIO.o):libs 在函数
xmlGzfileOpenW' 中: //tmp/libxml2.aeasy_install-(Y2MKTgxmlIO.o/):lxml -2.3/在build/function tmp/libxml2xmlGzfileOpenW-'中: 2.7.8//xmlIO.c:tmp1247/:easy_install -Y2MKTg/lxml-2.3/build/tmp/undefined libxml2-reference2.7.8/xmlIO.c:1247 :未定义`gzopen64' ./reference.libs/libxml2.a(xmlIO.o): 在功能上 ``xmlGzfileOpen_real':gzopen64'
/./tmp./libs/easy_installlibxml2.a-(xmlIO.oY2MKTg):/lxml- 在2.3功能/构建中 /tmp/
libxml2xmlGzfileOpen_real': -/2.7.8tmp//xmlIO.ceasy_install:1175-Y2MKTg/:lxml- 2.3/build/undefinedtmp/referencelibxml2-2.7.8/toxmlIO.c :
1175:gzopen64undefined'参考 到gzopen64'collect2:collect2:ld 返回 1 退出状态 ld 返回 1 退出状态 make[2]: *** [testRelax] 错误 1 make[2]: *** 正在等待 未完成的工作.... make[2]: *** [testSAX]错误1 .././.libs/libslibxml2.a/(libxml2.axmlIO.o(xmlIO.o)):: 在函数中
在函数中xmlGzfileOpenW'xmlGzfileOpenW':: / tmp/easy_install-Y2MKTg//tmp/lxmleasy_install--Y2MKTg/lxml-2.32.3//build/tmp/buildlibxml2-2.7.8//xmlIO.ctmp:/libxml2-1247: 未定义的引用 2.7.8gzopen64/xmlIO.c:1247: 未定义'.reference/.to libs/
gzopen64libxml2.a' (./.xmlIO.olibs/libxml2.a(xmlIO.o)): : 在 Infunction 函数中 xmlGzfileOpen_real '`: xmlGzfileOpen_real/': tmp//tmp/easy_install-Y2MKTgeasy_install-/Y2MKTg/lxml-lxml2.3-2.3//build/tmp/build/libxml2tmp/libxml2--2.7.82.7.8/xmlIO.c:/1175:xmlIO.c :1175:未定义未定义参考 参考``gzopen64' gzopen64'collect2:ld返回1退出 状态
collect2: ld 返回 1 退出状态 ./.libs/libxml2.a(xmlIO.o): 在 函数
xmlGzfileOpenW': /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2-2.7.8/xmlIO.c:1247: 对 gzopen64' 的未定义引用 ./.libs/libxml2.a(xmlIO.o): 在 函数
xmlGzfileOpen_real': /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2-2.7.8/xmlIO.c:1175: 对 gzopen64' 的未定义引用 Collect2: ld 返回 1 退出状态 make2:* [testSchemas]错误1 make2: [xmlcatalog] 错误 1 make2: [xmllint] 错误 1 make2:离开目录 /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2-2.7.8' make[1]: *** [全递归] 错误 1 make[1]: 离开目录
/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2-2.7.8' make: * [all] 错误 2 回溯 (最近一次调用最后一次):文件 “/usr/local/bin/easy_install-2.7”, 8号线,在 load_entry_point('setuptools==0.6c11', '控制台脚本', 'easy_install-2.7')() 文件 “build/bdist.linux-i686/egg/setuptools/command/easy_install.py”, 主文件中的第 1712 行 “build/bdist.linux-i686/egg/setuptools/command/easy_install.py”, 第 1700 行,在 with_ei_usage 文件中 “build/bdist.linux-i686/egg/setuptools/command/easy_install.py”, 文件中的第 1716 行 “/usr/local/lib/python2.7/distutils/core.py”, 第 152 行,设置中 dist.run_commands() 文件“/usr/local/lib/python2.7/distutils/dist.py”, 第 953 行,在 run_commands 中 self.run_command(cmd) 文件“/usr/local/lib/python2.7/distutils/dist.py”, 第 972 行,在 run_command 中 cmd_obj.run() 文件“build/bdist.linux-i686/egg/setuptools/command/easy_install.py”, 第 211 行,在运行文件中 “build/bdist.linux-i686/egg/setuptools/command/easy_install.py”, 第 446 行,在 easy_install 文件中 “build/bdist.linux-i686/egg/setuptools/command/easy_install.py”, 第 476 行,在 install_item 文件中 “build/bdist.linux-i686/egg/setuptools/command/easy_install.py”, install_eggs 文件中的第 655 行 “build/bdist.linux-i686/egg/setuptools/command/easy_install.py”, 第 930 行,在 build_and_install 文件中 “build/bdist.linux-i686/egg/setuptools/command/easy_install.py”, run_setup 文件中的第 919 行 “build/bdist.linux-i686/egg/setuptools/sandbox.py”, 第 62 行,在 run_setup 文件中 “build/bdist.linux-i686/egg/setuptools/sandbox.py”, 第 105 行,在运行文件中 “build/bdist.linux-i686/egg/setuptools/sandbox.py”, 文件中第 64 行 “setup.py”,第 130 行,位于
文件 “/tmp/easy_install-Y2MKTg/lxml-2.3/setupinfo.py”, 第 56 行,在 ext_modules 文件中 “/tmp/easy_install-Y2MKTg/lxml-2.3/buildlibxml.py”, 第 311 行,在 build_libxml2xslt 文件中 “/tmp/easy_install-Y2MKTg/lxml-2.3/buildlibxml.py”, cmmi 文件中的第 253 行 “/tmp/easy_install-Y2MKTg/lxml-2.3/buildlibxml.py”, 第 236 行,在 call_subprocess 中 异常:命令“make -j6”返回 代码2奇怪的是
还有更多的东西,如果您有兴趣,可以检查一下在这里
lxml import eTree
为什么不使用yum
?好吧,我能够通过yum安装Python-lxml
毫不费力地安装LXML,但这是CentOS的默认安装Python2.4。在这一点上,我现有的项目与2.4合作可能更容易。但是,从长远来看,我真正想解决这个问题。对于我自己,以及任何可能在将来遇到类似问题的人。
30 jun 2011 -- I am awarding @Pablo for this question, because of his answer.
I am still unable to properly install lxml 2.3 for reasons discussed in his comments. I gather for a little bit of work I could, but I have already spent a ridiculous amount of time on this problem. I have, however, written the code I needed and successfully installed lxml 2.2.8. The code functions with this version. Better yet, Pablo was the only one to properly diagnose the error. Which was libxslt needed to be updated to a version with support forexsltMathXpathCtxtRegister
I appreciate everyones help on this question.29 jun 2011 -- updating this question to reflect comments and to greater document my attempts
I should begin by saying I have tried every possible solution and install scenario imaginable. Yes, there are similar questions with this topic but their specific problem and solution are not my own. I have spent about 10-15 hours on this and I only continue to become more perplexed.
My Main Concern
In short, after installing lxml-2.3 from source or with easy_install-2.7 lxml
for python2.7 on centOs5.6, an alternate install of python, I cannot import the module properly. It will install without any obvious error, but It returns the following error when trying to import etree:
Python 2.7.2 (default, Jun 16 2011, 11:53:48)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> from lxml import etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/local/lib/python2.7/site-packages/lxml-2.3-py2.7-linux-x86_64.egg/lxml/etree.so: undefined symbol: exsltMathXpathCtxtRegister
What I have Tried
The two most common suggestions I have encountered are to make sure
libxml2 && libxml2-dev
andlibxslt1 && libxslt1-dev
They are. I have installed them through yum.$ yum list libxslt libxslt-devel libxml2
libxml2-devel Loaded plugins:
fastestmirror Installed Packages
libxml2.i386
2.6.26-2.1.2.8.el5_5.1 installed libxml2.x86_64
2.6.26-2.1.2.8.el5_5.1 installed libxml2-devel.i386
2.6.26-2.1.2.8.el5_5.1 installed libxml2-devel.x86_64
2.6.26-2.1.2.8.el5_5.1 installed libxslt.i386
1.1.17-2.el5_2.2 installed libxslt.x86_64
1.1.17-2.el5_2.2 installed libxslt-devel.i386
1.1.17-2.el5_2.2 installed libxslt-devel.x86_64
1.1.17-2.el5_2.2 installedRe-installed and Confirmed that
zlib && zlib-devel
are installed.$ yum list zlib zlib-devel Loaded
plugins: fastestmirror Installed
Packages zlib.i386
1.2.3-3 installed zlib.x86_64
1.2.3-3 installed zlib-devel.i386
1.2.3-3 installed zlib-devel.x86_64
1.2.3-3 installedConfirmed
python-devel
is installed. I think.a. According to several things I have read a way to check if python-devel is installed is to
import distutils
. regoogling this question brings this up quickly.b. @Keith suggested I tried to 'install' it anyhow, using this, however, I encountered an error
> error: cannot create %sourcedir /usr/src/redhat/SOURCES
so, I created the dir, and it has since installed. But with no success.
I can, however,
import xml.etree.cElementTree as etree
and/orimport xml.etree.ElementTree as etree
, but I do require some specific functionality fromlxml.etree
Oddly, If I try to install lxml under the assumption the dependencies not installed and try something like the following
sudo STATIC_DEPS=true easy_install-2.7 lxml 2>&1 | tee -a ~/.lxml
it fails with the outputting the error below. I should tersely note, for the unfamiliar, this seems to solve many people's issues as it will go out and retrieve any dependencies and install them for install lxml.
tail -100 ~/.lxml
gcc -DHAVE_CONFIG_H -I. -I./include
-I./include -D_REENTRANT -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include
-g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c runsuite.c gcc -DHAVE_CONFIG_H -I.
-I./include -I./include -D_REENTRANT -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include
-g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c testchar.c testapi.c: In function
‘test_xmlBufferSetAllocationScheme’:
testapi.c:18773: warning: comparison
of distinct pointer types lacks a cast
gcc -DHAVE_CONFIG_H -I. -I./include
-I./include -D_REENTRANT -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include
-g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c testdict.c gcc -DHAVE_CONFIG_H -I.
-I./include -I./include -D_REENTRANT -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include
-g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c runxmlconf.c gcc -DHAVE_CONFIG_H -I.
-I./include -I./include -D_REENTRANT -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include
-g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c testrecurse.c sed -e
's?\@XML_LIBDIR\@?-L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib?g'
\
-e 's?\@XML_INCLUDEDIR\@?-I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include/libxml2 -I/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/include?g'
\
-e 's?\@VERSION\@?2.7.8?g' \
-e 's?\@XML_LIBS\@?-lxml2 -lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm ?g' \
< ./xml2Conf.sh.in > xml2Conf.tmp \ && mv xml2Conf.tmp
xml2Conf.sh /bin/sh ./libtool --tag=CC
--mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -module -no-undefined -avoid-version -rpath /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -o testdso.la testdso.lo testapi.c: At top level: testapi.c:17989:
warning: ‘gen_xmlSchematronPtr’
defined but not used testapi.c:17992:
warning: ‘des_xmlSchematronPtr’
defined but not used testapi.c:18009:
warning:
‘gen_xmlSchematronParserCtxtPtr’
defined but not used testapi.c:18012:
warning:
‘des_xmlSchematronParserCtxtPtr’
defined but not used testapi.c:34157:
warning: ‘gen_xmlSAXHandlerPtr_ptr’
defined but not used testapi.c:34160:
warning: ‘des_xmlSAXHandlerPtr_ptr’
defined but not used libtool: link: ar
cru .libs/testdso.a testdso.o
libtool: link: ranlib .libs/testdso.a
libtool: link: ( cd ".libs" && rm -f
"testdso.la" && ln -s "../testdso.la"
"testdso.la" ) /bin/sh ./libtool
--tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -version-info 9:8:7 -ldl -o libxml2.la -rpath
/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib SAX.lo entities.lo encoding.lo
error.lo parserInternals.lo parser.lo
tree.lo hash.lo list.lo xmlIO.lo
xmlmemory.lo uri.lo valid.lo xlink.lo
HTMLparser.lo HTMLtree.lo debugXML.lo
xpath.lo xpointer.lo xinclude.lo
nanohttp.lo nanoftp.lo DOCBparser.lo
catalog.lo globals.lo threads.lo
c14n.lo xmlstring.lo xmlregexp.lo
xmlschemas.lo xmlschemastypes.lo
xmlunicode.lo xmlreader.lo relaxng.lo
dict.lo SAX2.lo xmlwriter.lo legacy.lo
chvalid.lo pattern.lo xmlsave.lo
xmlmodule.lo schematron.lo -lz
-L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm libtool: link: ar cru .libs/libxml2.a SAX.o entities.o
encoding.o error.o parserInternals.o
parser.o tree.o hash.o list.o xmlIO.o
xmlmemory.o uri.o valid.o xlink.o
HTMLparser.o HTMLtree.o debugXML.o
xpath.o xpointer.o xinclude.o
nanohttp.o nanoftp.o DOCBparser.o
catalog.o globals.o threads.o c14n.o
xmlstring.o xmlregexp.o xmlschemas.o
xmlschemastypes.o xmlunicode.o
xmlreader.o relaxng.o dict.o SAX2.o
xmlwriter.o legacy.o chvalid.o
pattern.o xmlsave.o xmlmodule.o
schematron.o libtool: link: ranlib
.libs/libxml2.a libtool: link: ( cd
".libs" && rm -f "libxml2.la" && ln -s
"../libxml2.la" "libxml2.la" ) /bin/sh
./libtool --tag=CC --mode=link gcc
-g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o xmllint xmllint.o ./libxml2.la -lz
-L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm /bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o xmlcatalog xmlcatalog.o ./libxml2.la
-lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm /bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testSchemas testSchemas.o ./libxml2.la
-lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm /bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testRelax testRelax.o ./libxml2.la
-lz -L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm /bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testSAX testSAX.o ./libxml2.la -lz
-L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -liconv -lm libtool: link: gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testSAX testSAX.o ./.libs/libxml2.a
-L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -ldl -lz /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib/libiconv.a
-lm libtool: link: gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testRelax testRelax.o
./.libs/libxml2.a
-L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -ldl -lz /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib/libiconv.a
-lm libtool: link: gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o xmlcatalog xmlcatalog.o
./.libs/libxml2.a
-L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -ldl -lz /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib/libiconv.a
-lm libtool: link: gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o testSchemas testSchemas.o
./.libs/libxml2.a
-L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -ldl -lz /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib/libiconv.a
-lm libtool: link: gcc -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -o xmllint xmllint.o ./.libs/libxml2.a
-L/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib -ldl -lz /tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2/lib/libiconv.a
-lm ./..libs/libxml2.a(/.xmlIO.o):libs In functionxmlGzfileOpenW':
libxml2xmlGzfileOpenW-':
//tmp/libxml2.aeasy_install-(Y2MKTgxmlIO.o/):lxml
-2.3/In build/function tmp/
2.7.8//xmlIO.c:tmp1247/:easy_install -Y2MKTg/lxml-2.3/build/tmp/undefined libxml2-reference2.7.8/xmlIO.c:1247
:to undefined`gzopen64'
./reference.libs/libxml2.a( xmlIO.o):
In functionto
``xmlGzfileOpen_real':gzopen64'/./tmp./libs/easy_installlibxml2.a-(xmlIO.oY2MKTg):/lxml-
In 2.3function/build
/tmp/libxml2xmlGzfileOpen_real':
1175: gzopen64undefined' reference
-/2.7.8tmp//xmlIO.ceasy_install:1175-Y2MKTg/:lxml-
2.3/build/undefinedtmp /referencelibxml2-2.7.8 /toxmlIO.c
:
togzopen64' collect2: collect2: ld
In function
returned 1 exit status ld returned 1
exit status make[2]: *** [testRelax]
Error 1 make[2]: *** Waiting for
unfinished jobs.... make[2]: ***
[testSAX] Error 1
.././.libs/libslibxml2.a/(libxml2.axmlIO.o(xmlIO.o))::
In functionxmlGzfileOpenW'xmlGzfileOpenW':: /
2.7.8gzopen64/xmlIO.c:1247:
tmp/easy_install-Y2MKTg//tmp/lxmleasy_install--Y2MKTg/lxml-2.32.3//build/tmp/buildlibxml2-2.7.8//xmlIO.ctmp:/libxml2-1247:
undefined reference to
undefined' .reference/ .to
libs/gzopen64libxml2.a'
xmlGzfileOpen_real '`:
(./.xmlIO.olibs/libxml2.a(xmlIO.o)): :
In Infunction function
xmlGzfileOpen_real/':
tmp//tmp/easy_install-Y2MKTgeasy_install-/Y2MKTg/lxml-lxml2.3-2.3//build/tmp/build/libxml2tmp/libxml2--2.7.82.7.8/xmlIO.c:/1175:xmlIO.c
:1175: undefinedundefined reference
reference toto ``gzopen64'
gzopen64'collect2: ld returned 1 exit
statuscollect2: ld returned 1 exit status
./.libs/libxml2.a(xmlIO.o): In
functionxmlGzfileOpenW':
gzopen64'
/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2-2.7.8/xmlIO.c:1247:
undefined reference to
./.libs/libxml2.a(xmlIO.o): In
functionxmlGzfileOpen_real':
gzopen64'
/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2-2.7.8/xmlIO.c:1175:
undefined reference to
collect2: ld returned 1 exit status
make2: * [testSchemas] Error 1
make2: [xmlcatalog] Error 1
make2: [xmllint] Error 1
make2: Leaving directory/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2-2.7.8'
/tmp/easy_install-Y2MKTg/lxml-2.3/build/tmp/libxml2-2.7.8'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory
make: * [all] Error 2 Traceback
(most recent call last): File
"/usr/local/bin/easy_install-2.7",
line 8, in
load_entry_point('setuptools==0.6c11',
'console_scripts',
'easy_install-2.7')() File
"build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 1712, in main File
"build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 1700, in with_ei_usage File
"build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 1716, in File
"/usr/local/lib/python2.7/distutils/core.py",
line 152, in setup
dist.run_commands() File "/usr/local/lib/python2.7/distutils/dist.py",
line 953, in run_commands
self.run_command(cmd) File "/usr/local/lib/python2.7/distutils/dist.py",
line 972, in run_command
cmd_obj.run() File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 211, in run File
"build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 446, in easy_install File
"build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 476, in install_item File
"build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 655, in install_eggs File
"build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 930, in build_and_install File
"build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 919, in run_setup File
"build/bdist.linux-i686/egg/setuptools/sandbox.py",
line 62, in run_setup File
"build/bdist.linux-i686/egg/setuptools/sandbox.py",
line 105, in run File
"build/bdist.linux-i686/egg/setuptools/sandbox.py",
line 64, in File
"setup.py", line 130, in
File
"/tmp/easy_install-Y2MKTg/lxml-2.3/setupinfo.py",
line 56, in ext_modules File
"/tmp/easy_install-Y2MKTg/lxml-2.3/buildlibxml.py",
line 311, in build_libxml2xslt File
"/tmp/easy_install-Y2MKTg/lxml-2.3/buildlibxml.py",
line 253, in cmmi File
"/tmp/easy_install-Y2MKTg/lxml-2.3/buildlibxml.py",
line 236, in call_subprocess
Exception: Command "make -j6" returned
code 2
there was considerably more, and if you are interested you can check it out here
I have tried several other methods of installation. including @agilevic's which returned an error virtually identical to the one above. Most others install effortlessly, but all fail on from lxml import etree
Why not use a yum
? Well, I was able to install lxml effortlessly through yum install python-lxml
, but that was centOs' default installation of python2.4. At this point it is probably easier to retool my existing project to work with 2.4. In the long run, however, I would truly like to resolve this issue. For myself, and anyone else who may encounter a similar problem in the future.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您的 libxslt 没有
exsltMathXpathCtxtRegister
将其删除,并手动安装较新的版本(1.1.26 应该可以正常工作)。旧版本的 lxml 也可以工作,请尝试使用
easy_install lxml==2.2.8
Your libxslt do not have
exsltMathXpathCtxtRegister
remove it, and manually install a newer version (1.1.26 should work fine).An older version of lxml may work too, try with
easy_install lxml==2.2.8
对未来的谷歌用户说的话 - 我带着同样的症状来到这里,但安装了足够新的 libxslt 打包版本(1.1.26)。大约花了 10 分钟,我才意识到我的路径中还有一个古老的版本(与
casapy
天文学包一起安装)。这个故事的寓意是:运行
locate libxslt
来查找旧版本,并检查您的$LD_LIBRARY_PATH
! (当然,这通常适用于任何库冲突)。A word to future googlers - I arrived here with the same symptom, but a sufficiently recent packaged version of libxslt installed (1.1.26). Took about 10 minutes before I realised I also had an ancient version in my path, (installed with the
casapy
astronomy package).Moral of the story: run a
locate libxslt
to find old versions, and check against your$LD_LIBRARY_PATH
! (Of course, this applies to any library conflict in general).读取你的输出,链接器输出了一个错误:
对 gzopen64 的未定义引用
该错误出现在 call_subprocess 中的
lxml-2.3/buildlibxml.py", line 236
中,并再次出现在make -j6< /code>
我在这里找到了一个线程: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=15524 具有相同的编译器错误并提出建议。
该帖子的 OP 后来评论道:
所以,我建议重新安装 zlib 和 zlib-devel,然后再次尝试安装 lxml。
Reading your output it looks like the linker output an error:
undefined reference to gzopen64
That error bubbled up into
lxml-2.3/buildlibxml.py", line 236, in call_subprocess
, which bubbled up again intomake -j6
I found a thread here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=15524 that had the same compiler error. With a suggestion
And the OP of that thread later commented:
So, I'd suggest re-installing zlib and zlib-devel, and then try to install lxml again.
您最好从源代码编译 LibXML2 和 LibXSLT。假设您的安装前缀应与您的自定义 Python 相同,即 /usr/local,具体方法如下(可能有较新版本的软件,因此,请先检查):
如果上述内容无法编译,则有可能是您应该尝试从 yum 包满足的其他依赖项,通常这些是缺少头文件的某些库和/或 *-devel 包。
一旦完成,
或者
You best best may be compiling LibXML2 and LibXSLT from sources. Assuming the prefix for your installation should be the same as your custom Python, which appears to be /usr/local, here's how (there may be newer version of the software so, check that first):
If the above does not compile, there may be other dependencies that you should try to satisfy from yum packages, typically these would be certain libraries and/or *-devel packages with missing header files.
Once that's done either
or
确保您的计算机上安装了 libxslt-dev 和 libxml2-dev(我猜您可以使用 yum 来完成此操作);没有它们,lxml 将无法构建。
Make sure you have libxslt-dev and libxml2-dev installed on your machine (you can do this with yum I guess); lxml won't build without them.