lxml 5.x crashes at runtime on macOS ARM with symbol not found _exsltDateXpathCtxtRegister

Bug #2063945 reported by Jason R. Coombs
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Undecided
scoder

Bug Description

Attempting to import lxml.html on macOS with ARM architecture under Python 3.8 crashes:

```
 @ py -3.8 -m pip-run -v lxml -- -c "import lxml.html"
Collecting lxml
  Using cached lxml-5.2.1-cp38-cp38-macosx_10_9_universal2.whl.metadata (3.4 kB)
Using cached lxml-5.2.1-cp38-cp38-macosx_10_9_universal2.whl (6.0 MB)
Installing collected packages: lxml
Successfully installed lxml-5.2.1
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/var/folders/f2/2plv6q2n7l932m2x004jlw340000gn/T/pip-run-kjqmiykz/lxml/html/__init__.py", line 49, in <module>
    from .. import etree
ImportError: dlopen(/var/folders/f2/2plv6q2n7l932m2x004jlw340000gn/T/pip-run-kjqmiykz/lxml/etree.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '_exsltDateXpathCtxtRegister'
```

This issue has been reported [here](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/issues/1718) where the prescribed workaround is to rely on `lxml<5`. In [this answer](https://stackoverflow.com/a/77867171/70170), users experiencing a similar error are able to work around it by using `lxml<5`.

Installing from source works around the issue:

```
 jaraco.home main @ py -3.8 -m pip-run -v --no-cache --no-binary lxml lxml -- -c "import lxml.html" && echo done
Collecting lxml
  Downloading lxml-5.2.1.tar.gz (3.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.7/3.7 MB 22.6 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: lxml
  Building wheel for lxml (pyproject.toml) ... done
  Created wheel for lxml: filename=lxml-5.2.1-cp38-cp38-macosx_14_0_arm64.whl size=1483942 sha256=5446f4087e092482d470ebacfe8d14ef8a484a72abf085efb1057b7c1d31f1e2
  Stored in directory: /private/var/folders/f2/2plv6q2n7l932m2x004jlw340000gn/T/pip-ephem-wheel-cache-bkqb2nhw/wheels/20/0d/9f/3662e113348035a354cab0d23d4cff4ab95bd8f8d69bdec8f1
Successfully built lxml
Installing collected packages: lxml
Successfully installed lxml-5.2.1
done
```

Unfortunately, for a project dependent on lxml, there's no good way to declare "always build from source when on macOS with ARM on Python 3.8", so there's no easy way to work around this issue for affected projects.

Any chance the wheel in PyPI can be re-compiled to avoid this issue?

Revision history for this message
Andreas Maier (maiera) wrote :

I have the same issue on macOS 14.4.1 and lxml 5.2.1.
Log: https://github.com/pywbem/pywbem/actions/runs/8864089712/job/24338908529

Going back to lxml 4.9.4 (on macOS 14.4.1) circumvents the issue.
Log: https://github.com/pywbem/pywbem/actions/runs/8864275249/job/24339285229

Going back to macos 12.7.4 (with lxml 5.2.1) also circumvents the issue.
Log: https://github.com/pywbem/pywbem/actions/runs/8768044331/job/24061981288

In all cases, the following was used:
arm64
Python 3.8
libxml2 2.12.6
libxsslt 1.1.39

Revision history for this message
scoder (scoder) wrote :

Thanks for the report. I have removed the 3.8 wheel from PyPI:
lxml-5.2.1-cp38-cp38-macosx_10_9_universal2.whl

Changed in lxml:
assignee: nobody → scoder (scoder)
status: New → Fix Released
Revision history for this message
Jason R. Coombs (jaraco) wrote :

It's working great now without any special handling. Thanks!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.