python安装lxml库出错_python – 在Centos 7上安装lxml – 错误:命令...

该博客讲述了在Python 3.4的虚拟环境中,尝试安装lxml库时遇到'gcc'命令失败的问题,详细记录了错误信息并提供了可能的解决方案,涉及到了libxml2和libxslt的开发包安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我在虚拟环境中使用python 3.4:

(af)[root@domain backend]# pip --version

pip 7.1.0 from /home/af/af-stage/backend/.ves/af/lib/python3.4/site-packages (python 3.4)

安装lxml失败“错误:命令’gcc’失败,退出状态为4”:

(af)[root@domain backend]# pip install lxml

You are using pip version 7.1.0, however version 7.1.2 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

Collecting lxml

Using cached lxml-3.5.0.tar.gz

Building wheels for collected packages: lxml

Running setup.py bdist_wheel for lxml

Complete output from command /home/af/af-stage/backend/.ves/af/bin/python3.4 -c "import setuptools;__file__='/tmp/pip-build-tlogtyk2/lxml/setup.py';exec(compile(open(__file__).read().replace('

', '

'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpod9hcw0ypip-wheel-:

Building lxml version 3.5.0.

Building without Cython.

Using build configuration of libxslt 1.1.28

Building against libxml2/libxslt in the following directory: /usr/lib64

running bdist_wheel

running build

running build_py

creating build

creating build/lib.linux-x86_64-3.4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

creating build/lib.linux-x86_64-3.4/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-3.4/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-3.4/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-3.4/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-3.4/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-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1

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

running build_ext

building 'lxml.etree' extension

creating build/temp.linux-x86_64-3.4

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

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

gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/libxml2 -Isrc/lxml/includes -I/usr/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -w

{standard input}: Assembler messages:

{standard input}:1531298: Error: unknown pseudo-op: `.uleb'

gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See for instructions.

Compile failed: command 'gcc' failed with exit status 4

creating tmp

cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitpm92p5c8.c -o tmp/xmlXPathInitpm92p5c8.o

cc tmp/xmlXPathInitpm92p5c8.o -L/usr/lib64 -lxml2 -o a.out

error: command 'gcc' failed with exit status 4

----------------------------------------

Failed building wheel for lxml

Failed to build lxml

Installing collected packages: lxml

Running setup.py install for lxml

Complete output from command /home/af/af-stage/backend/.ves/af/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-tlogtyk2/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('

', '

'), __file__, 'exec'))" install --record /tmp/pip-99hwjy1o-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/af/af-stage/backend/.ves/af/include/site/python3.4/lxml:

Building lxml version 3.5.0.

Building without Cython.

Using build configuration of libxslt 1.1.28

Building against libxml2/libxslt in the following directory: /usr/lib64

running install

running build

running build_py

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

running build_ext

building 'lxml.etree' extension

gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/libxml2 -Isrc/lxml/includes -I/usr/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -w

{standard input}: Assembler messages:

{standard input}:1320351: Error: unknown pseudo-op: `.uleb1'

gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See for instructions.

Compile failed: command 'gcc' failed with exit status 4

cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInit3tj66iu0.c -o tmp/xmlXPathInit3tj66iu0.o

cc tmp/xmlXPathInit3tj66iu0.o -L/usr/lib64 -lxml2 -o a.out

error: command 'gcc' failed with exit status 4

----------------------------------------

Command "/home/af/af-stage/backend/.ves/af/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-tlogtyk2/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('

', '

'), __file__, 'exec'))" install --record /tmp/pip-99hwjy1o-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/af/af-stage/backend/.ves/af/include/site/python3.4/lxml" failed with error code 1 in /tmp/pip-build-tlogtyk2/lxml

笔记:

我已经完成了yum install libxslt-devel libxml2-devel

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值