【问题标题】:Matlab-Python compiler SDK fails with "undefined symbol: XML_SetHashSalt"Matlab-Python 编译器 SDK 因“未定义符号:XML_SetHashSalt”而失败
【发布时间】:2018-10-31 07:30:26
【问题描述】:

我正在使用带有 Matlab R2018a 的 Ubuntu 16.04 64 位并使用 Python 3.6(以及已安装但未使用的 3.5 和 2.7)。

我有一个 Matlab 代码,它试图通过使用并遵循Matlab Compiler SDK for Python 上的说明从 Python 调用。我按照此链接上的所有说明操作,创建我的 Matlab-Python 包装器(Web)安装程序并安装它们,按照安装程序的建议更改 LD_LIBRARY_PATH。我已经尝试过他们展示的 MagicSquarePkg 示例,并且在这种方法下效果很好。然而,MagicSquarePkg 没有使用任何 Matlab 工具箱函数;我的代码可以。在我使用我的代码执行此过程后,我收到以下错误:

<username>:~/MatlabWorkspace/rs_cuboid_measure_script_python_attempt2/for_testing$ python3.6

Python 3.6.5 (default, Mar 29 2018, 03:28:50) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import rs_cuboid_measure_script_python *my Matlab module*
Exception caught during initialization of Python interface. Details: 
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0: undefined symbol: 
XML_SetHashSalt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<$HOME>/MatlabWorkspace/rs_cuboid_measure_script_python_attempt2/for_testing/rs_cuboid_measure_script_python/__init__.py", line 283, in <module>
_pir.import_cppext()
File "<$HOME>/MatlabWorkspace/rs_cuboid_measure_script_python_attempt2/for_testing/rs_cuboid_measure_script_python/__init__.py", line 276, in import_cppext
self.cppext_handle = importlib.import_module("matlabruntimeforpython" + self.interpreter_version)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0: undefined symbol: XML_SetHashSalt

这里的 rs_cuboid_measure_script_python 是我的 Matlab 模块,在 Matlab 中运行时可以完美运行。

我在各种论坛上查看了以下相关答案:

1) https://www.mathworks.com/matlabcentral/answers/267099-matlab-s-python-engine-crashes-minidom(最相关)

如果我遵循此链接上的建议并

 import pyexpat 

在导入我的模块之前,我遇到了段错误:

>>> import pyexpat
>>> import rs_cuboid_measure_script_python
Segmentation fault (core dumped)

2)Python application crash with error "ImportError: pyexpat.x86_64-linux-gnu.so: undefined symbol: XML_SetHashSalt"

基于此链接,依赖项是:

<username>:/usr/lib/x86_64-linux-gnu$ ldd libpython3.6m.so.1.0

linux-vdso.so.1 =>  (0x00007ffed491a000)
libexpat.so.1 => /usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64/libexpat.so.1 (0x00007f90cb2b4000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f90cb09a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f90cae7d000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f90cac79000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f90caa76000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f90ca76d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f90ca3a3000)
/lib64/ld-linux-x86-64.so.2 (0x00007f90cbbd1000)

3) 根据 Mathworks 支持的建议,我按照link 上的说明重新安装了 python,但这并没有改变任何东西。我得到与上面相同的错误

其他一些可能相关或不相关的链接:

4)https://askubuntu.com/questions/601106/trying-to-run-hp-toolbox-from-hplip-but-gives-python-errors/601178#601178

5) https://github.com/sqlmapproject/sqlmap/issues/2194 注意:我已将 LD_LIBRARY_PATH 变量更改为:

:~$ echo $LD_LIBRARY_PATH 
:/usr/local/MATLAB/MATLAB_Runtime/v94/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v94/bin/glnxa64/:/usr/local/MATLAB/MATLAB_Runtime/v94/sys/os/glnxa64/

根据Matlab compiler SDK website 给出的说明 (注意:正确的路径不完全是链接上的路径,而是上面控制台输出中的路径,这证实了我的 Mathworks 支持)。

6)https://github.com/opencv/opencv/issues/5445

:/usr/lib/x86_64-linux-gnu$ strings libpython3.6m.so.1.0 | grep Salt
XML_SetHashSalt

感谢任何解决此问题的帮助。

编辑:凭直觉,我用 Python2.7 而不是 3.6 运行了我的 Matlab 模块,它似乎适用于 2.7 但不适用于 3.6

:~/MatlabWorkspace/rs_cuboid_measure_script_python_attempt2/for_testing$ python2.7
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rs_cuboid_measure_script_python
>>> rs = rs_cuboid_measure_script_python.initialize()
>>> rs.rs_cuboid_measure_script_python()
Not enough input arguments. *this is OK this means my function is getting called*

【问题讨论】:

    标签: dependencies python-3.6 matlab-compiler


    【解决方案1】:

    我遇到了这个确切的问题。同样的错误。使用 Python 2.7 而不是 Python 3.5 也对我有用。谢谢。

    但是我真的很想知道如何让它在 3.6 上运行,因为我打算在 3.6 上运行的 Django 服务器上使用 Matlab 程序。

    【讨论】:

    • 什么对你有用?这应该是评论,而不是我所看到的答案。
    【解决方案2】:

    我也有同样的问题。已解决:

    cd /full_path_to_matlab_mcrroot/v94/bin/glnxa64
    mv libexpat.so.1 libexpat.so.1.NOFIND
    

    感谢https://bbs.archlinux.org/viewtopic.php?pid=1112017#p1112017

    • 说明:

    /full_path_to_matlab_mcrroot/v94/bin/glnxa64/libexpat.so.1 指向libexpat.so.1.5.0

    但是

    /lib/x86_64-linux-gnu/libexpat.so.1 指向libexpat.so.1.6.0

    【讨论】:

      【解决方案3】:
      export LD_LIBRARY_PATH=/lib64/:$LD_LIBRARY_PATH
      

      【讨论】:

      • 请解释一下!
      猜你喜欢
      • 2020-12-04
      • 1970-01-01
      • 2020-11-17
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      • 2022-06-29
      • 1970-01-01
      相关资源
      最近更新 更多