美文网首页
cpython-38-x86_64-linux-gnu.so:

cpython-38-x86_64-linux-gnu.so:

作者: dhz120 | 来源:发表于2022-07-07 14:15 被阅读0次

    背景:

    ubuntu 20.04下,使用secureCRT 9 执行python 3脚本时,报_tkinter.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyFloat_Type

    问题分析:

    参考https://github.com/ninia/jep/issues/206

    PyFloat_Type should be defined in libpython. It would seem _struct.cpython-38-x86_64-linux-gnu.so does not depend on libpython so libpython will need to be loaded into the global namespace. By default JNI will load libpython in a local namespace. Try setting LD_PRELOAD to the location of your libpython so, to force it to be loaded globally.
    

    大概意思是,PyFloat_Type是在libpython里定义的,但是cpython-38-x86_64-linux-gnu.so并没有依赖libpython,所有就需要我们通过设置一下环境变量LD_PRELOAD来解决

    解决办法

    将libpython的库放在LD_PRELOAD即可

    1. 如果不知道libpython库在哪,可以通过find命令找一下
    # 切换到跟目录
    cd /
    # 查找libpython的库名及位置
    sudo find . -name "libpython*"
    
    1. 找到之后,将libpython设置的LD_PRELOAD,可以在~/.bashrc中进行设置或者可以在命令行执行先测试一下也行
    export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libpython3.8.so
    
    1. 设置好之后,可以重启软件(secureCRT)测试好不好使

    相关文章

      网友评论

          本文标题:cpython-38-x86_64-linux-gnu.so:

          本文链接:https://www.haomeiwen.com/subject/ruhvbrtx.html