8

我一直在尝试使用安装 lxml pip install lxml,但出现以下错误。我以前用过apt-get install python-dev libxml2 libxml2-dev libxslt-dev(在其他答案中建议),但我仍然得到同样的错误。我没有使用 control-c。

pip install lxml
Downloading/unpacking lxml
  Downloading lxml-3.2.4.tar.gz (3.3MB): 3.3MB downloaded
  Running setup.py egg_info for package lxml
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.2.4.
    Building without Cython.
    Using build configuration of libxslt 1.1.26
    Building against libxml2/libxslt in the following directory: /usr/lib/x86_64-linux-gnu

    warning: no previously-included files found matching '*.py'
    warning: no files found matching '*.txt' under directory 'src/lxml/tests'
Installing collected packages: lxml
  Running setup.py install for lxml
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.2.4.
    Building without Cython.
    Using build configuration of libxslt 1.1.26
    Building against libxml2/libxslt in the following directory: /usr/lib/x86_64-linux-gnu
    building 'lxml.etree' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/home/mlkang/Envs/env1/build/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o
    src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_4data':
    src/lxml/lxml.etree.c:97799:74: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxData' from incompatible pointer type [enabled by default]
    src/lxml/lxml.etree.c:97400:12: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'
    src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_6start':
    src/lxml/lxml.etree.c:97936:75: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxStart' from incompatible pointer type [enabled by default]
    src/lxml/lxml.etree.c:97100:18: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'
    src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_8end':
    src/lxml/lxml.etree.c:97994:73: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxEnd' from incompatible pointer type [enabled by default]
    src/lxml/lxml.etree.c:97324:18: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'
    src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_10pi':
    src/lxml/lxml.etree.c:98152:72: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxPi' from incompatible pointer type [enabled by default]
    src/lxml/lxml.etree.c:97440:18: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'
    src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_12comment':
    src/lxml/lxml.etree.c:98205:77: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxComment' from incompatible pointer type [enabled by default]
    src/lxml/lxml.etree.c:97566:18: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'
    src/lxml/lxml.etree.c: In function '__pyx_f_4lxml_5etree__xslt_resolve_from_python':
    src/lxml/lxml.etree.c:136086:9: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch]
    src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_4XSLT_18__call__':
    src/lxml/lxml.etree.c:140160:81: warning: passing argument 1 of '__pyx_f_4lxml_5etree_12_XSLTContext__copy' from incompatible pointer type [enabled by default]
    src/lxml/lxml.etree.c:138095:52: note: expected 'struct __pyx_obj_4lxml_5etree__XSLTContext *' but argument is of type 'struct __pyx_obj_4lxml_5etree__BaseContext *'
    src/lxml/lxml.etree.c: In function '__pyx_f_4lxml_5etree__copyXSLT':
    src/lxml/lxml.etree.c:141558:79: warning: passing argument 1 of '__pyx_f_4lxml_5etree_12_XSLTContext__copy' from incompatible pointer type [enabled by default]
    src/lxml/lxml.etree.c:138095:52: note: expected 'struct __pyx_obj_4lxml_5etree__XSLTContext *' but argument is of type 'struct __pyx_obj_4lxml_5etree__BaseContext *'
    src/lxml/lxml.etree.c: At top level:
    src/lxml/lxml.etree.c:12770:13: warning: '__pyx_f_4lxml_5etree_displayNode' defined but not used [-Wunused-function]
gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
error: command 'gcc' failed with exit status 4
Complete output from command /home/mlkang/Envs/env1/bin/python -c "import setuptools;__file__='/home/mlkang/Envs/env1/build/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zVBvtO-record/install-record.txt --single-version-externally-managed --install-headers /home/mlkang/Envs/env1/include/site/python2.7:
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

  warnings.warn(msg)

Building lxml version 3.2.4.

Building without Cython.

Using build configuration of libxslt 1.1.26

Building against libxml2/libxslt in the following directory: /usr/lib/x86_64-linux-gnu

running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

creating build/lib.linux-x86_64-2.7/lxml

copying src/lxml/__init__.py -> build/lib.linux-x86_64-2.7/lxml

copying src/lxml/_elementpath.py -> build/lib.linux-x86_64-2.7/lxml

copying src/lxml/ElementInclude.py -> build/lib.linux-x86_64-2.7/lxml

copying src/lxml/cssselect.py -> build/lib.linux-x86_64-2.7/lxml

copying src/lxml/usedoctest.py -> build/lib.linux-x86_64-2.7/lxml

copying src/lxml/pyclasslookup.py -> build/lib.linux-x86_64-2.7/lxml

copying src/lxml/doctestcompare.py -> build/lib.linux-x86_64-2.7/lxml

copying src/lxml/sax.py -> build/lib.linux-x86_64-2.7/lxml

copying src/lxml/builder.py -> build/lib.linux-x86_64-2.7/lxml

creating build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/__init__.py -> build/lib.linux-x86_64-2.7/lxml/includes

creating build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/diff.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/_diffcommand.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/__init__.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/clean.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/html5parser.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/_setmixin.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/usedoctest.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/soupparser.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/defs.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/ElementSoup.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/_html5builder.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/formfill.py -> build/lib.linux-x86_64-2.7/lxml/html

copying src/lxml/html/builder.py -> build/lib.linux-x86_64-2.7/lxml/html

creating build/lib.linux-x86_64-2.7/lxml/isoschematron

copying src/lxml/isoschematron/__init__.py -> build/lib.linux-x86_64-2.7/lxml/isoschematron

copying src/lxml/lxml.etree.h -> build/lib.linux-x86_64-2.7/lxml

copying src/lxml/lxml.etree_api.h -> build/lib.linux-x86_64-2.7/lxml

copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/schematron.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/config.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/xslt.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/c14n.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/relaxng.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/uri.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/xinclude.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/xpath.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/tree.pxd -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-2.7/lxml/includes

copying src/lxml/includes/etree_defs.h -> build/lib.linux-x86_64-2.7/lxml/includes

creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources

creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/rng

copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/rng

creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl

copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl

copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl

creating build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1

copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-x86_64-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1

running build_ext

building 'lxml.etree' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

creating build/temp.linux-x86_64-2.7/src/lxml

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/home/mlkang/Envs/env1/build/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o

src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_4data':

src/lxml/lxml.etree.c:97799:74: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxData' from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:97400:12: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'

src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_6start':

src/lxml/lxml.etree.c:97936:75: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxStart' from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:97100:18: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'

src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_8end':

src/lxml/lxml.etree.c:97994:73: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxEnd' from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:97324:18: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'

src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_10pi':

src/lxml/lxml.etree.c:98152:72: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxPi' from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:97440:18: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'

src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_11TreeBuilder_12comment':

src/lxml/lxml.etree.c:98205:77: warning: passing argument 1 of '__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxComment' from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:97566:18: note: expected 'struct __pyx_obj_4lxml_5etree_TreeBuilder *' but argument is of type 'struct __pyx_obj_4lxml_5etree__SaxParserTarget *'

src/lxml/lxml.etree.c: In function '__pyx_f_4lxml_5etree__xslt_resolve_from_python':

src/lxml/lxml.etree.c:136086:9: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch]

src/lxml/lxml.etree.c: In function '__pyx_pf_4lxml_5etree_4XSLT_18__call__':

src/lxml/lxml.etree.c:140160:81: warning: passing argument 1 of '__pyx_f_4lxml_5etree_12_XSLTContext__copy' from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:138095:52: note: expected 'struct __pyx_obj_4lxml_5etree__XSLTContext *' but argument is of type 'struct __pyx_obj_4lxml_5etree__BaseContext *'

src/lxml/lxml.etree.c: In function '__pyx_f_4lxml_5etree__copyXSLT':

src/lxml/lxml.etree.c:141558:79: warning: passing argument 1 of '__pyx_f_4lxml_5etree_12_XSLTContext__copy' from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:138095:52: note: expected 'struct __pyx_obj_4lxml_5etree__XSLTContext *' but argument is of type 'struct __pyx_obj_4lxml_5etree__BaseContext *'

src/lxml/lxml.etree.c: At top level:

src/lxml/lxml.etree.c:12770:13: warning: '__pyx_f_4lxml_5etree_displayNode' defined but not used [-Wunused-function]

gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.

error: command 'gcc' failed with exit status 4

----------------------------------------
4

2 回答 2

28

试试这个来获得deps:

apt-get build-dep python-lxml
于 2013-11-11T00:37:05.147 回答
11

我正是这个问题。原来是内存问题——我在只有 500MB RAM 的服务器上安装了依赖于 lxml 的reporter.py,其中只有 150MB 是可用的。我杀掉了一些东西以获得大约 300MB 的免费空间,并设法挤出了 lxml 的安装。(观看 TOP 显示可用内存一度下降到 4MB!)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48796

于 2014-03-07T17:18:44.080 回答