安装Python的lxml时出错(BeautifulSoup)

时间:2018-04-01 10:02:51

标签: python beautifulsoup pip pycharm lxml

我正在尝试为我的Python项目安装lxml库(我正在运行MacOS High Sierra 10.13.3)。 首先,我尝试通过PyCharm-Preferences-Project Interpreter-install软件包lxml安装它。它给了我一个error

正如PyCharm建议的那样,我试图通过pip3 install lxml安装它 它再次给了我一个错误,这是日志:

MacBook-Pro-Kamil:~ kamilsaitov$ pip3 install lxml
Collecting lxml
  Using cached lxml-4.2.1.tar.gz
Installing collected packages: lxml
  Running setup.py install for lxml ... error
    Complete output from command /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn/T/pip-build-5gw20m5d/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 /var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn/T/pip-ls51tzm1-record/install-record.txt --single-version-externally-managed --compile:
    Building lxml version 4.2.1.
    Building without Cython.
    Using build configuration of libxslt 1.1.32
    Building against libxml2/libxslt in the following directory: /opt/local/lib
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.6-intel-3.7
    creating build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/_elementpath.py -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/sax.py -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/pyclasslookup.py -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/__init__.py -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/builder.py -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/doctestcompare.py -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/usedoctest.py -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/cssselect.py -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/ElementInclude.py -> build/lib.macosx-10.6-intel-3.7/lxml
    creating build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/__init__.py -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    creating build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/soupparser.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/defs.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/_setmixin.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/clean.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/_diffcommand.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/html5parser.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/__init__.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/formfill.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/builder.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/ElementSoup.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/_html5builder.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/usedoctest.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    copying src/lxml/html/diff.py -> build/lib.macosx-10.6-intel-3.7/lxml/html
    creating build/lib.macosx-10.6-intel-3.7/lxml/isoschematron
    copying src/lxml/isoschematron/__init__.py -> build/lib.macosx-10.6-intel-3.7/lxml/isoschematron
    copying src/lxml/etree.h -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/etree_api.h -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/lxml.etree.h -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/lxml.etree_api.h -> build/lib.macosx-10.6-intel-3.7/lxml
    copying src/lxml/includes/xmlerror.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/c14n.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/xmlschema.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/__init__.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/schematron.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/tree.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/uri.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/etreepublic.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/xpath.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/htmlparser.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/xslt.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/config.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/xmlparser.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/xinclude.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/dtdvalid.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/relaxng.pxd -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    copying src/lxml/includes/etree_defs.h -> build/lib.macosx-10.6-intel-3.7/lxml/includes
    creating build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources
    creating build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources/rng
    copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources/rng
    creating build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources/xsl
    creating build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.macosx-10.6-intel-3.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.macosx-10.6-intel-3.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.macosx-10.6-intel-3.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    running build_ext
    building 'lxml.etree' extension
    creating build/temp.macosx-10.6-intel-3.7
    creating build/temp.macosx-10.6-intel-3.7/src
    creating build/temp.macosx-10.6-intel-3.7/src/lxml
    /usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -DCYTHON_CLINE_IN_TRACEBACK=0 -I/opt/local/include -I/opt/local/include/libxml2 -Isrc -Isrc/lxml/includes -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/lxml/etree.c -o build/temp.macosx-10.6-intel-3.7/src/lxml/etree.o -w -flat_namespace
    src/lxml/etree.c:244141:21: error: no member named 'exc_state' in 'struct _ts'
        *type = tstate->exc_state.exc_type;
                ~~~~~~  ^
    src/lxml/etree.c:244142:22: error: no member named 'exc_state' in 'struct _ts'
        *value = tstate->exc_state.exc_value;
                 ~~~~~~  ^
    src/lxml/etree.c:244143:19: error: no member named 'exc_state' in 'struct _ts'
        *tb = tstate->exc_state.exc_traceback;
              ~~~~~~  ^
    src/lxml/etree.c:244156:24: error: no member named 'exc_state' in 'struct _ts'
        tmp_type = tstate->exc_state.exc_type;
                   ~~~~~~  ^
    src/lxml/etree.c:244157:25: error: no member named 'exc_state' in 'struct _ts'
        tmp_value = tstate->exc_state.exc_value;
                    ~~~~~~  ^
    src/lxml/etree.c:244158:22: error: no member named 'exc_state' in 'struct _ts'
        tmp_tb = tstate->exc_state.exc_traceback;
                 ~~~~~~  ^
    src/lxml/etree.c:244159:13: error: no member named 'exc_state' in 'struct _ts'
        tstate->exc_state.exc_type = type;
        ~~~~~~  ^
    src/lxml/etree.c:244160:13: error: no member named 'exc_state' in 'struct _ts'
        tstate->exc_state.exc_value = value;
        ~~~~~~  ^
    src/lxml/etree.c:244161:13: error: no member named 'exc_state' in 'struct _ts'
        tstate->exc_state.exc_traceback = tb;
        ~~~~~~  ^
    src/lxml/etree.c:244240:24: error: no member named 'exc_state' in 'struct _ts'
        tmp_type = tstate->exc_state.exc_type;
                   ~~~~~~  ^
    src/lxml/etree.c:244241:25: error: no member named 'exc_state' in 'struct _ts'
        tmp_value = tstate->exc_state.exc_value;
                    ~~~~~~  ^
    src/lxml/etree.c:244242:22: error: no member named 'exc_state' in 'struct _ts'
        tmp_tb = tstate->exc_state.exc_traceback;
                 ~~~~~~  ^
    src/lxml/etree.c:244243:13: error: no member named 'exc_state' in 'struct _ts'
        tstate->exc_state.exc_type = local_type;
        ~~~~~~  ^
    src/lxml/etree.c:244244:13: error: no member named 'exc_state' in 'struct _ts'
        tstate->exc_state.exc_value = local_value;
        ~~~~~~  ^
    src/lxml/etree.c:244245:13: error: no member named 'exc_state' in 'struct _ts'
        tstate->exc_state.exc_traceback = local_tb;
        ~~~~~~  ^
    src/lxml/etree.c:244429:24: error: no member named 'exc_state' in 'struct _ts'
        tmp_type = tstate->exc_state.exc_type;
                   ~~~~~~  ^
    src/lxml/etree.c:244430:25: error: no member named 'exc_state' in 'struct _ts'
        tmp_value = tstate->exc_state.exc_value;
                    ~~~~~~  ^
    src/lxml/etree.c:244431:22: error: no member named 'exc_state' in 'struct _ts'
        tmp_tb = tstate->exc_state.exc_traceback;
                 ~~~~~~  ^
    src/lxml/etree.c:244432:13: error: no member named 'exc_state' in 'struct _ts'
        tstate->exc_state.exc_type = *type;
        ~~~~~~  ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.
    Compile failed: command '/usr/bin/clang' failed with exit status 1
    creating var
    creating var/folders
    creating var/folders/8r
    creating var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn
    creating var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn/T
    cc -I/opt/local/include -I/opt/local/include/libxml2 -I/usr/include/libxml2 -c /var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn/T/xmlXPathInitdxco6fje.c -o var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn/T/xmlXPathInitdxco6fje.o
    /var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn/T/xmlXPathInitdxco6fje.c:2:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
    main (int argc, char **argv) {
    ^
    1 warning generated.
    cc var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn/T/xmlXPathInitdxco6fje.o -L/opt/local/lib -lxml2 -o a.out
    error: command '/usr/bin/clang' failed with exit status 1

    ----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn/T/pip-build-5gw20m5d/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 /var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn/T/pip-ls51tzm1-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/8r/_4lh1jlx28134rmqz9zkk8rc0000gn/T/pip-build-5gw20m5d/lxml/

然后我尝试了我在互联网上找到的sudo port install py27-lxml 它确实安装了,但在PyCharm中没有用(我假设因为它是用于python 2.7)

这就是问题所在。有没有办法为我安装lxml或者我的Python中有错误? (虽然我试图卸载Python并再次安装它,并为lxml和BeautifulSoup这样做)如何解决这个问题?

0 个答案:

没有答案