Skip to content

pip Install python-docx==1.1.1 raise error in python 3.12, ERROR: Failed building wheel for lxml<=4.9.2,>=3.1.0 (in mac os) #1383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
flyingpang opened this issue Apr 30, 2024 · 8 comments · Fixed by BlackBoiler/python-docx#23

Comments

@flyingpang
Copy link

I tested that Python3.12 can successfully install lxml==5.2.1 in my mac and also can install python-docx==1.1.0
But pip install python-docx==1.1.1 required lxml<=4.9.2,>=3.1.0, raise errors as blow:

I try to upgrade pip, setuptools and wheel, The error is still unresolved. Could you please improve lxml version requirement in the future release?

`Using cached python_docx-1.1.1-py3-none-any.whl (242 kB)
Building wheels for collected packages: lxml
Building wheel for lxml (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for lxml (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [175 lines of output]
:117: SyntaxWarning: invalid escape sequence '.'
:67: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
Building lxml version 4.9.2.
Building without Cython.
Building against libxml2 2.9.4 and libxslt 1.1.29
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-cpython-312
creating build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/_elementpath.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/sax.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/pyclasslookup.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/init.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/builder.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/doctestcompare.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/usedoctest.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/cssselect.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/ElementInclude.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml
creating build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/init.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
creating build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/soupparser.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/defs.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/_setmixin.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/clean.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/_diffcommand.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/html5parser.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/init.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/formfill.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/builder.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/ElementSoup.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/_html5builder.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/usedoctest.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
copying src/lxml/html/diff.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/html
creating build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron
copying src/lxml/isoschematron/init.py -> build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron
copying src/lxml/etree.h -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/etree_api.h -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/lxml.etree.h -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/lxml.etree_api.h -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/objectify.pyx -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/etree.pyx -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/public-api.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/xmlid.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/cleanup.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/xslt.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/xpath.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/debug.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/serializer.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/classlookup.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/saxparser.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/objectpath.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/relaxng.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/xinclude.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/iterparse.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/parser.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/dtd.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/apihelpers.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/xmlerror.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/readonlytree.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/extensions.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/xmlschema.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/schematron.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/docloader.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/nsclasses.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/parsertarget.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/xsltext.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/proxy.pxi -> build/lib.macosx-10.9-universal2-cpython-312/lxml
copying src/lxml/includes/xmlerror.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/c14n.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/xmlschema.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/init.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/schematron.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/tree.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/uri.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/etreepublic.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/xpath.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/htmlparser.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/xslt.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/config.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/xmlparser.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/xinclude.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/dtdvalid.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/relaxng.pxd -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
copying src/lxml/includes/etree_defs.h -> build/lib.macosx-10.9-universal2-cpython-312/lxml/includes
creating build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron/resources
creating build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron/resources/rng
copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron/resources/rng
creating build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron/resources/xsl
creating build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.macosx-10.9-universal2-cpython-312/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.9-universal2-cpython-312/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.9-universal2-cpython-312/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.macosx-10.9-universal2-cpython-312/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating build/temp.macosx-10.9-universal2-cpython-312
creating build/temp.macosx-10.9-universal2-cpython-312/src
creating build/temp.macosx-10.9-universal2-cpython-312/src/lxml
clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -arch x86_64 -g -DCYTHON_CLINE_IN_TRACEBACK=0 -Isrc -Isrc/lxml/includes -I/Users/Flyingpang/long-image-text-env/include -I/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c src/lxml/etree.c -o build/temp.macosx-10.9-universal2-cpython-312/src/lxml/etree.o -w -flat_namespace
src/lxml/etree.c:262394:36: error: no member named 'curexc_traceback' in 'struct _ts'
PyObject* tmp_tb = tstate->curexc_traceback;
~~~~~~ ^
src/lxml/etree.c:262397:21: error: no member named 'curexc_traceback' in 'struct _ts'
tstate->curexc_traceback = tb;
~~~~~~ ^
src/lxml/etree.c:263340:53: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)op1)->ob_digit;
~~~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:263457:53: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)op1)->ob_digit;
~~~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:265182:53: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)op1)->ob_digit;
~~~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:267536:55: error: no member named 'gi_code' in 'PyGenObject'
if (PyGen_CheckExact(obj) && ((PyGenObject*)obj)->gi_code && ((PyCodeObject )((PyGenObject)obj)->gi_code)->co_flags & CO_ITERABLE_COROUTINE) {
~~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:267536:104: error: no member named 'gi_code' in 'PyGenObject'
if (PyGen_CheckExact(obj) && ((PyGenObject*)obj)->gi_code && ((PyCodeObject )((PyGenObject)obj)->gi_code)->co_flags & CO_ITERABLE_COROUTINE) {
~~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:268588:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:268643:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:268897:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:268952:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:269093:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:269148:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:269289:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:269344:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:269523:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:269578:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:269757:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
src/lxml/etree.c:269812:55: error: no member named 'ob_digit' in 'struct _longobject'
const digit* digits = ((PyLongObject*)x)->ob_digit;
~~~~~~~~~~~~~~~~~~ ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Compile failed: command '/usr/bin/clang' failed with exit code 1
creating var
creating var/folders
creating var/folders/rp
creating var/folders/rp/_b7j9qm55gg5627hy8zw5djm0000gn
creating var/folders/rp/_b7j9qm55gg5627hy8zw5djm0000gn/T
cc -I/usr/include/libxml2 -c /var/folders/rp/_b7j9qm55gg5627hy8zw5djm0000gn/T/xmlXPathInitv4mdlpck.c -o var/folders/rp/_b7j9qm55gg5627hy8zw5djm0000gn/T/xmlXPathInitv4mdlpck.o
cc var/folders/rp/_b7j9qm55gg5627hy8zw5djm0000gn/T/xmlXPathInitv4mdlpck.o -lxml2 -o a.out
error: command '/usr/bin/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
Failed to build lxml
ERROR: Could not build wheels for lxml, which is required to install pyproject.toml-based projects`

@musicinmybrain
Copy link
Contributor

With this and #1385, I think it looks like pinning lxml to the previous major version in 5a80006 did more harm than good.

@scanny
Copy link
Contributor

scanny commented Apr 30, 2024

@musicinmybrain it looks like #1385 is unrelated to the lxml pin.

However a build problem on Python 3.12 is enough to consider reverting this pin ...

Yeah, I'm going to pull that pin. It looks like the cure is worse than the disease. The intent was to allow it to install smoothly on Apple Silicon, but if it breaks elsewhere that's just as bad. We'll just have to live with some folks with newer Macs having to work a little harder to get lxml installed and hope that problem goes away.

@evaneill
Copy link

I'm getting the same error on pip install. If it ends up being relevant:

  • python version 3.12.2
  • pip version 24.0
  • setuptools 67.6.1
  • wheel 0.40.0

OSX 13.4.1

@scanny
Copy link
Contributor

scanny commented Apr 30, 2024

@flyingpang @musicinmybrain @evaneill I've pulled that pin on the develop branch up on GitHub.

Can you try a clean install from that branch and see if that resolves this problem?

$ pip uninstall python-docx
$ pip install git+https://github.com/python-openxml/python-docx@develop

@evaneill
Copy link

@flyingpang @musicinmybrain @evaneill I've pulled that pin on the develop branch up on GitHub.

Can you try a clean install from that branch and see if that resolves this problem?

$ pip uninstall python-docx
$ pip install git+https://github.com/python-openxml/python-docx@develop

Thanks, I can now install the develop branch in a clean environment

@scanny
Copy link
Contributor

scanny commented Apr 30, 2024

@evaneill thanks! That's super helpful :)

I'll push a new maintenance release here ...

@flyingpang
Copy link
Author

https://github.com/python-openxml/python-docx@develop

I tested in my clean python3.12 env, it can successful install develop branch. Thanks!

@scanny
Copy link
Contributor

scanny commented May 1, 2024

Okay, v1.1.2 is up on PyPI :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants