python-3.xpiplxmltermux

Problem installing lxml on Termux on Android 10 with Python 3.11.6 and pip 23.3.1


pip install lxml

python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [174 lines of output]
      Building lxml version 4.9.3.
      /data/data/com.termux/files/usr/tmp/pip-install-_o6bvhue/lxml_187c40a112b84500b9b645b18187e159/setup.py:67: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
        import pkg_resources
      Building without Cython.
      Building against libxml2 2.12.1 and libxslt 1.1.39
      Building against libxml2/libxslt in the following directory: /data/data/com.termux/files/usr/lib
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-aarch64-cpython-311
      creating build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/ElementInclude.py -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/__init__.py -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/_elementpath.py -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/builder.py -> build/lib.linux-aarch64-cpython-311/lxml                                                             copying src/lxml/cssselect.py -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/doctestcompare.py -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/pyclasslookup.py -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/sax.py -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/usedoctest.py -> build/lib.linux-aarch64-cpython-311/lxml
      creating build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/__init__.py -> build/lib.linux-aarch64-cpython-311/lxml/includes
      creating build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/ElementSoup.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/__init__.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/_diffcommand.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/_html5builder.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/_setmixin.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/builder.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/clean.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/defs.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/diff.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/formfill.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/html5parser.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/soupparser.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      copying src/lxml/html/usedoctest.py -> build/lib.linux-aarch64-cpython-311/lxml/html
      creating build/lib.linux-aarch64-cpython-311/lxml/isoschematron
      copying src/lxml/isoschematron/__init__.py -> build/lib.linux-aarch64-cpython-311/lxml/isoschematron
      copying src/lxml/etree.h -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/etree_api.h -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/lxml.etree.h -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/lxml.etree_api.h -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/etree.pyx -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/objectify.pyx -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/apihelpers.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/classlookup.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/cleanup.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/debug.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/docloader.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/dtd.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/extensions.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/iterparse.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/nsclasses.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/objectpath.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/parser.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/parsertarget.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/proxy.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/public-api.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/readonlytree.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/relaxng.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/saxparser.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/schematron.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/serializer.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/xinclude.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/xmlerror.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/xmlid.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/xmlschema.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/xpath.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/xslt.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/xsltext.pxi -> build/lib.linux-aarch64-cpython-311/lxml
      copying src/lxml/includes/__init__.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/c14n.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/config.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/relaxng.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/schematron.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/tree.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/uri.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/xinclude.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/xpath.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/xslt.pxd -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/etree_defs.h -> build/lib.linux-aarch64-cpython-311/lxml/includes
      copying src/lxml/includes/lxml-version.h -> build/lib.linux-aarch64-cpython-311/lxml/includes
      creating build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources
      creating build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources/rng
      copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources/rng
      creating build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources/xsl
      copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources/xsl
      copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources/xsl
      creating build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-aarch64-cpython-311/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-aarch64-cpython-311/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-aarch64-cpython-311/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      running build_ext
      building 'lxml.etree' extension
      creating build/temp.linux-aarch64-cpython-311
      creating build/temp.linux-aarch64-cpython-311/src
      creating build/temp.linux-aarch64-cpython-311/src/lxml
      aarch64-linux-android-clang -DNDEBUG -g -fwrapv -O3 -Wall -fstack-protector-strong -O3 -fstack-protector-strong -O3 -fPIC -DCYTHON_CLINE_IN_TRACEBACK=0 -I/data/data/com.termux/files/usr/include/libxml2 -I/data/data/com.termux/files/usr/include -Isrc -Isrc/lxml/includes -I/data/data/com.termux/files/usr/include/python3.11 -c src/lxml/etree.c -o build/temp.linux-aarch64-cpython-311/src/lxml/etree.o -w
      src/lxml/etree.c:113152:38: error: incompatible function pointer types assigning to 'xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') from 'void (void *, xmlError *)' (aka 'void (void *, struct _xmlError *)') [-Wincompatible-function-pointer-types]
       113152 |   __pyx_v_self->_c_ctxt->sax->serror = __pyx_f_4lxml_5etree__receiveParserError;
              |                                      ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      src/lxml/etree.c:117640:25: error: incompatible function pointer types assigning to 'xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') from 'void (void *, xmlError *)' (aka 'void (void *, struct _xmlError *)') [-Wincompatible-function-pointer-types]
       117640 |     __pyx_v_sax->serror = __pyx_f_4lxml_5etree__receiveParserError;
              |                         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      src/lxml/etree.c:181724:28: error: incompatible function pointer types assigning to 'xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') from 'void (void *, xmlError *)' (aka 'void (void *, struct _xmlError *)') [-Wincompatible-function-pointer-types]
       181724 |   __pyx_v_xpathCtxt->error = __pyx_f_4lxml_5etree__receiveXPathError;
              |                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      src/lxml/etree.c:218998:60: error: incompatible function pointer types passing 'void (void *, xmlError *)' (aka 'void (void *, struct _xmlError *)') to parameter of type 'xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') [-Wincompatible-function-pointer-types]
       218998 |   xmlRelaxNGSetParserStructuredErrors(__pyx_v_parser_ctxt, __pyx_f_4lxml_5etree__receiveError, ((void *)__pyx_v_self->__pyx_base._error_log));
              |                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /data/data/com.termux/files/usr/include/libxml2/libxml/relaxng.h:155:30: note: passing argument to parameter 'serror' here
        155 |                                          xmlStructuredErrorFunc serror,
            |                                                                 ^
      src/lxml/etree.c:219416:60: error: incompatible function pointer types passing 'void (void *, xmlError *)' (aka 'void (void *, struct _xmlError *)') to parameter of type 'xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') [-Wincompatible-function-pointer-types]
       219416 |     xmlRelaxNGSetValidStructuredErrors(__pyx_v_valid_ctxt, __pyx_f_4lxml_5etree__receiveError, ((void *)__pyx_v_self->__pyx_base._error_log));
              |                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /data/data/com.termux/files/usr/include/libxml2/libxml/relaxng.h:184:31: note: passing argument to parameter 'serror' here
        184 |                                           xmlStructuredErrorFunc serror, void *ctx);
            |                                                                  ^
      src/lxml/etree.c:220305:59: error: incompatible function pointer types passing 'void (void *, xmlError *)' (aka 'void (void *, struct _xmlError *)') to parameter of type 'xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') [-Wincompatible-function-pointer-types]
       220305 |   xmlSchemaSetParserStructuredErrors(__pyx_v_parser_ctxt, __pyx_f_4lxml_5etree__receiveError, ((void *)__pyx_v_self->__pyx_base._error_log));
              |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /data/data/com.termux/files/usr/include/libxml2/libxml/xmlschemas.h:156:30: note: passing argument to parameter 'serror' here
        156 |                                          xmlStructuredErrorFunc serror,
            |                                                                 ^
      src/lxml/etree.c:220848:59: error: incompatible function pointer types passing 'void (void *, xmlError *)' (aka 'void (void *, struct _xmlError *)') to parameter of type 'xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') [-Wincompatible-function-pointer-types]
       220848 |     xmlSchemaSetValidStructuredErrors(__pyx_v_valid_ctxt, __pyx_f_4lxml_5etree__receiveError, ((void *)__pyx_v_self->__pyx_base._error_log));
              |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /data/data/com.termux/files/usr/include/libxml2/libxml/xmlschemas.h:185:30: note: passing argument to parameter 'serror' here
        185 |                                          xmlStructuredErrorFunc serror,
            |                                                                 ^
      src/lxml/etree.c:221613:66: error: incompatible function pointer types passing 'void (void *, xmlError *)' (aka 'void (void *, struct _xmlError *)') to parameter of type 'xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') [-Wincompatible-function-pointer-types]
       221613 |     xmlSchemaSetValidStructuredErrors(__pyx_v_self->_valid_ctxt, __pyx_f_4lxml_5etree__receiveError, ((void *)__pyx_v_error_log));
              |                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /data/data/com.termux/files/usr/include/libxml2/libxml/xmlschemas.h:185:30: note: passing argument to parameter 'serror' here
        185 |                                          xmlStructuredErrorFunc serror,
            |                                                                 ^
      src/lxml/etree.c:222790:63: error: incompatible function pointer types passing 'void (void *, xmlError *)' (aka 'void (void *, struct _xmlError *)') to parameter of type 'xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') [-Wincompatible-function-pointer-types]
       222790 |     xmlSchematronSetValidStructuredErrors(__pyx_v_valid_ctxt, __pyx_f_4lxml_5etree__receiveError, ((void *)__pyx_v_self->__pyx_base._error_log));
              |                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /data/data/com.termux/files/usr/include/libxml2/libxml/schematron.h:105:31: note: passing argument to parameter 'serror' here
        105 |                                           xmlStructuredErrorFunc serror,
            |                                                                  ^
      9 errors generated.
      Compile failed: command '/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang' failed with exit code 1
      creating data
      creating data/data
      creating data/data/com.termux
      creating data/data/com.termux/files
      creating data/data/com.termux/files/usr
      creating data/data/com.termux/files/usr/tmp
      cc -I/data/data/com.termux/files/usr/include/libxml2 -I/data/data/com.termux/files/usr/include -I/usr/include/libxml2 -c /data/data/com.termux/files/usr/tmp/xmlXPathInitqoa6gvtp.c -o data/data/com.termux/files/usr/tmp/xmlXPathInitqoa6gvtp.o
      /data/data/com.termux/files/usr/tmp/xmlXPathInitqoa6gvtp.c:3:5: warning: 'xmlXPathInit' is deprecated [-Wdeprecated-declarations]
          3 |     xmlXPathInit();
            |     ^
      /data/data/com.termux/files/usr/include/libxml2/libxml/xpath.h:562:1: note: 'xmlXPathInit' has been explicitly marked deprecated here
        562 | XML_DEPRECATED
            | ^
      /data/data/com.termux/files/usr/include/libxml2/libxml/xmlversion.h:447:43: note: expanded from macro 'XML_DEPRECATED'
        447 | #    define XML_DEPRECATED __attribute__((deprecated))
            |                                           ^
      1 warning generated.
      cc data/data/com.termux/files/usr/tmp/xmlXPathInitqoa6gvtp.o -L/data/data/com.termux/files/usr/lib -lxml2 -o a.out
      error: command '/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lxml
  Running setup.py clean for lxml
Failed to build lxml
ERROR: Could not build wheels for lxml, which is required to install pyproject.toml-based projects

I am going to Install lxml on Termux version Android 10 Requirements Python 3.11.6 Pip 23.3. 1


Solution

  • Clear data in your termux.

    Then open termux and command these sequentially:

    apt update && apt upgrade
    
    pkg install python libxml2 libxslt pkg-config
    
    pip install cython wheel
    
    CFLAGS="-Wno-error=incompatible-function-pointer-types -O0" pip install lxml
    

    See my picture. I just installed