Python application crash with error “ImportError: pyexpat.x86_64-linux-gnu.so: undefined symbol: XML_SetHashSalt”

匿名 (未验证) 提交于 2019-12-03 01:45:01

问题:

We use matlab's python engine to interface with matlab code from python. There seems to be some conflict with the used libexpact.so library.

A minimal buggy example would be:

#!/usr/bin/env python from xml.dom import minidom import matlab.engine  a = minidom.parse("solution_example.xml") print(a) 

This produces the output:

  File "./minimal.py", line 9, in <module>     a = minidom.parse("solution_example.xml")   File "/usr/lib/python2.7/xml/dom/minidom.py", line 1917, in parse     from xml.dom import expatbuilder   File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 32, in <module>     from xml.parsers import expat   File "/usr/lib/python2.7/xml/parsers/expat.py", line 4, in <module>     from pyexpat import * ImportError: /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so: undefined symbol: XML_SetHashSalt 

However, the program runs fine when the line import matlab.engine is omitted.

Any ideas what the problem could be or how we could debug the python import procedure?

Thanks in advance!

回答1:

I faced the same error message this morning and after looking around, I found this solution works for me. So I re-post here. Hope this help in future.

"It seems that this is caused by library conflicts with libexpat. I did ldd /usr/lib/python2.7/lib-dynload/pyexpat.so and realized that my libexpat.so.1 was pointing to /usr/local/lib/libexpat.so.1 rather than /lib/x86_64-linux-gnu/libexpat.so.1 (the former referencing an outdated version, 1.5.2 instead of 1.6.0). I don't know where the libexpat in /usr/local/lib came from.

I hide my libexpat files in /usr/local/lib (renamed with .backup appended) and now running ldd /usr/lib/python2.7/lib-dynload/pyexpat.so displays the line "libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1" and update-manager works correctly."

https://ubuntuforums.org/showthread.php?t=2094005



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!