A-A+
alpine Failed to build lxml 【Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?】

【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】
百度的RASP 扫描器真的是坑啊。。。大坑啊。。也可能是测试版的问题吧。。。
【Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?】解决方案,我们先看看报错信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | Running setup.py install for lxml ... error ERROR: Command errored out with exit status 1: command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jhj7sdbk/lxml/setup.py'"'"'; __file__='"'"'/tmp/pip-i nstall-jhj7sdbk/lxml/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code , __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-5_8hm09b/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/ include/python3.7m/lxml cwd: /tmp/pip-install-jhj7sdbk/lxml/ Complete output (95 lines): Building lxml version 4.4.1. Building without Cython. ERROR: b'/bin/sh: xslt-config: not found\n' ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt running install running build running build_py creating build creating build/lib.linux-x86_64-3.7 creating build/lib.linux-x86_64-3.7/lxml copying src/lxml/sax.py -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/_elementpath.py -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/builder.py -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/ElementInclude.py -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/__init__.py -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/usedoctest.py -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/cssselect.py -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/pyclasslookup.py -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/doctestcompare.py -> build/lib.linux-x86_64-3.7/lxml creating build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/__init__.py -> build/lib.linux-x86_64-3.7/lxml/includes creating build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/diff.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/ElementSoup.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/html5parser.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/builder.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/__init__.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/usedoctest.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/_setmixin.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/clean.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/soupparser.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/_html5builder.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/_diffcommand.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/formfill.py -> build/lib.linux-x86_64-3.7/lxml/html copying src/lxml/html/defs.py -> build/lib.linux-x86_64-3.7/lxml/html creating build/lib.linux-x86_64-3.7/lxml/isoschematron copying src/lxml/isoschematron/__init__.py -> build/lib.linux-x86_64-3.7/lxml/isoschematron copying src/lxml/etree.h -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/etree_api.h -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/lxml.etree.h -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/lxml.etree_api.h -> build/lib.linux-x86_64-3.7/lxml copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/xinclude.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/config.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/__init__.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/uri.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/xslt.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/tree.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/xpath.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/relaxng.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/c14n.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/schematron.pxd -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/etree_defs.h -> build/lib.linux-x86_64-3.7/lxml/includes copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-3.7/lxml/includes creating build/lib.linux-x86_64-3.7/lxml/isoschematron/resources creating build/lib.linux-x86_64-3.7/lxml/isoschematron/resources/rng copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-x86_64-3.7/lxml/isoschematron/resources/rng creating build/lib.linux-x86_64-3.7/lxml/isoschematron/resources/xsl copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-x86_64-3.7/lxml/isoschematron/resources/xsl copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-x86_64-3.7/lxml/isoschematron/resources/xsl creating build/lib.linux-x86_64-3.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-3.7/lxml/isoschematron/resources/xsl/iso-schematr on-xslt1 copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-x86_64-3.7/lxml/isoschematron/resources/xsl/iso-schem atron-xslt1 copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-x86_64-3.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-3.7/lxml/isoschematron/resources/xsl/iso-sc hematron-xslt1 copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-x86_64-3.7/lxml/isoschematron/resources/xsl/iso-schema tron-xslt1 copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-x86_64-3.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 running build_ext building 'lxml.etree' extension creating build/temp.linux-x86_64-3.7 creating build/temp.linux-x86_64-3.7/src creating build/temp.linux-x86_64-3.7/src/lxml gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -DCYTHON_CLINE_IN_TRACEBACK=0 -Isrc -Isrc/lxml/includes -I/ usr/local/include/python3.7m -c src/lxml/etree.c -o build/temp.linux-x86_64-3.7/src/lxml/etree.o -w In file included from src/lxml/etree.c:692: src/lxml/includes/etree_defs.h:14:10: fatal error: libxml/xmlversion.h: No such file or directory #include "libxml/xmlversion.h" ^~~~~~~~~~~~~~~~~~~~~ compilation terminated. Compile failed: command 'gcc' failed with exit status 1 cc -I/usr/include/libxml2 -c /tmp/xmlXPathInit42gzsg_w.c -o tmp/xmlXPathInit42gzsg_w.o /tmp/xmlXPathInit42gzsg_w.c:1:10: fatal error: libxml/xpath.h: No such file or directory #include "libxml/xpath.h" ^~~~~~~~~~~~~~~~ compilation terminated. ********************************************************************************* Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed? ********************************************************************************* error: command 'gcc' failed with exit status 1 ---------------------------------------- ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jhj7sdbk/lxml/setup. py'"'"'; __file__='"'"'/tmp/pip-install-jhj7sdbk/lxml/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n' "'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-5_8hm09b/install-record.txt --single-version-externally-managed --comp ile --install-headers /usr/local/include/python3.7m/lxml Check the logs for full command output. |
解决方案:
##注意,我是在alpine 容器中,所以执行命令略有不同。
apk --no-cache add --update libxml2-utils libxslt gcc musl-dev libxslt-dev
##如果不行,那就执行。
apk add libxml2-utils libxslt gcc musl-dev libxslt-dev
我是在python安装下面软件过程中出现的问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | aiohttp==3.5.4 aiomysql==0.0.20 async-timeout==3.0.1 atomicwrites==1.3.0 attrs==19.1.0 certifi==2019.3.9 chardet==3.0.4 ConcurrentLogHandler==0.9.1 coverage==4.5.3 idna==2.8 importlib-metadata==0.18 jsonschema==3.0.1 lru-dict==1.1.6 more-itertools==7.0.0 multidict==4.5.2 packaging==19.0 peewee==3.9.6 peewee-async==0.6.3a0 pluggy==0.12.0 psutil==5.6.3 py==1.8.0 PyMySQL==0.9.2 PyYAML==5.1.1 pyparsing==2.4.0 pyrsistent==0.15.2 pytest-cov==2.7.1 requests==2.22.0 six==1.12.0 tornado==6.0.2 urllib3==1.25.3 wcwidth==0.1.7 yarl==1.3.0 zipp==0.5.1 dictdiffer==0.8.0 lxml==4.4.1 aiowebsocket==1.0.0.dev2 |
布施恩德可便相知重
微信扫一扫打赏
支付宝扫一扫打赏