Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: ImportError: /home/travis/miniconda/envs/env/lib/python3.11/lib-dynload/pyexpat.cpython-311-x86_64-linux-gnu.so: undefined symbol: XML_SetReparseDeferralEnabled #28235

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
qci-amos opened this issue May 16, 2024 · 7 comments

Comments

@qci-amos
Copy link

Bug summary

New failure in our ci this morning

Code for reproduction

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT

Actual outcome

    from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT
  File "/home/travis/miniconda/envs/env/lib/python3.11/site-packages/matplotlib/backends/backend_qt5agg.py", line 7, in <module>
    from .backend_qtagg import (    # noqa: F401, E402 # pylint: disable=W0611
  File "/home/travis/miniconda/envs/env/lib/python3.11/site-packages/matplotlib/backends/backend_qtagg.py", line 10, in <module>
    from .backend_agg import FigureCanvasAgg
  File "/home/travis/miniconda/envs/env/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py", line 31, in <module>
    from matplotlib.backend_bases import (
  File "/home/travis/miniconda/envs/env/lib/python3.11/site-packages/matplotlib/backend_bases.py", line 49, in <module>
    from matplotlib import (
  File "/home/travis/miniconda/envs/env/lib/python3.11/site-packages/matplotlib/text.py", line 16, in <module>
    from .font_manager import FontProperties
  File "/home/travis/miniconda/envs/env/lib/python3.11/site-packages/matplotlib/font_manager.py", line 41, in <module>
    import plistlib
  File "/home/travis/miniconda/envs/env/lib/python3.11/plistlib.py", line 70, in <module>
    from xml.parsers.expat import ParserCreate
  File "/home/travis/miniconda/envs/env/lib/python3.11/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: /home/travis/miniconda/envs/env/lib/python3.11/lib-dynload/pyexpat.cpython-311-x86_64-linux-gnu.so: undefined symbol: XML_SetReparseDeferralEnabled

Expected outcome

no exception

Additional information

No response

Operating system

Ubuntu 22.04.3 LTS

Matplotlib Version

matplotlib-3.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Matplotlib Backend

No response

Python version

3.11

Jupyter version

n/a

Installation

pip

@ksunden
Copy link
Member

ksunden commented May 16, 2024

xref python/cpython#115398

I'm not too sure there is much for us to do here... the line in matplotlib that is failing is an import of a standard library module (plistlib).

In particular, the comment on the above thread that is directed to "Linux distro maintainers" indicates that care must be taken to ensure that (lib)expat and python are not out of sync with each other.

It looks like you are using conda, so the same caution would apply to the source of your python installation (either upstream anaconda main or e.g. conda forge) My first recommendation would be to ensure that all updates are applied, as a compatible expat appears to be available on conda.

It looks like conda forge does not provide a pin for expat version in the python recipe:

https://github.com/conda-forge/python-feedstock/blob/3732e621ad28b925e402c3c1d8542bac029920ad/recipe/meta.yaml#L181

All that said, and while I stand by my assessment that the primary problem is upstream packaging here, plistlib is, I believe, only actually used in MacOS specific code (other than the import)... so I think we could possibly move the import such that it doesn't happen on other platforms. I do believe you would still have problems with other xml tasks which use the stdlib module, though, so while the specific problem could be mitigated, it is not a full solution.

@qci-amos
Copy link
Author

I see what you mean by standard library, however, the reason why matplotlib seemed implicated is because it's the dependency which changed yesterday (though we didn't go back and check mpl 3.8). But maybe that was just a coincidence?

@ksunden
Copy link
Member

ksunden commented May 16, 2024

Yes, we did introduce that import in this version, that much is true.

But I still think it is mostly just indicating a broken upstream package chain, that likely is fixed by ensuring upgrades are applied.

@QuLogic
Copy link
Member

QuLogic commented May 16, 2024

I tried this in a new environment:

$ conda create -p /tmp/foo python=3.11
$ conda activate /tmp/foo
$ python
>>> import plistlib

and it imports fine. Then I also tried with -c conda-forge to try those packages, and it also worked. This might be something specific to your environment, and I would try to be sure you are getting a completely clean environment.

@qci-amos
Copy link
Author

Ah, ok, got it. πŸ‘

We are able to address it like this:

sudo apt install libexpat1 libexpat1-dev

but it feels like I shouldn't need to do that. In our case, the travis config looks like this:

language: python
cache: pip
python: 3.11
dist: jammy

and then we use a more or less conventional conda installation (from miniconda).

The main suspect that I see in all that is that we're using jammy. Maybe that's just too old? Or that at some point someone will update it?

Ok, feel free to close this issue.

@ksunden
Copy link
Member

ksunden commented May 16, 2024

I would have expected you to get expat from conda, actually, but yeah, CPython introduced a version dependency on expat.

@ksunden ksunden closed this as completed May 16, 2024
@andychenbruce
Copy link

For me I was on python 3.12 and expat 3.6.2 on conda so I downgraded expat with conda install expat=3.6.1 which fixed it.

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

No branches or pull requests

4 participants