[Python] Why: python3.11: error while loading shared libraries: libpython3.11.so.1.0: cannot...

Discussão em 'Python' iniciado por Stack, Agosto 2, 2025.

  1. Stack

    Stack Membro Participativo

    On Ubuntu, Python3.11 cannot find libpython3.11.so.1.0.

    Here is my system information:

    PRETTY_NAME="Ubuntu 24.04.1 LTS"
    NAME="Ubuntu"
    VERSION_ID="24.04"
    VERSION="24.04.1 LTS (Noble Numbat)VERSION_CODENAME=noble
    ID=ubuntu
    ID_LIKE=debian
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    UBUNTU_CODENAME=noble
    LOGO=ubuntu-logo


    On my system, I have installed python3 and python3-dev, with versions python3.12.3.At the same time, I compiled Python 3.12.7 using the following compilation instructions:

    ./configure --enable-loadable-sqlite-extensions --enable-optimizations --with-lto=full --enable-shared
    make
    make altinstall


    Then everything is normal, here are the details:

    linux-vdso.so.1 (0x00007ffdbd726000)
    libpython3.12.so.1.0 => /usr/local/lib/libpython3.12.so.1.0 (0x000077c52ea00000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000077c52e600000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x000077c52f165000)
    /lib64/ld-linux-x86-64.so.2 (0x000077c52f26a000)


    However, when I need to install other versions of Python, such as Python3.11.10, issues arise.

    The compilation configuration is identical to that of Python3.12, but the following problem occurs:

    python3.11: error while loading shared libraries: libpython3.11.so.1.0: cannot open shared object file: No such file or directory


    I resolved the issue by doing the following:

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib


    However, I don't understand why this problem occurred. Was there a configuration error somewhere?

    Here is the detailed information:

    > ll /usr/local/lib/
    drwxr-xr-x 5 root root 4096 Oct 3 13:42 ./
    drwxr-xr-x 10 root root 4096 Apr 24 18:47 ../
    lrwxrwxrwx 1 root root 20 Oct 3 13:42 libpython3.11.so -> libpython3.11.so.1.0*
    -rwxr-xr-x 1 root root 25185720 Oct 3 13:42 libpython3.11.so.1.0*
    lrwxrwxrwx 1 root root 20 Oct 2 16:19 libpython3.12.so -> libpython3.12.so.1.0*
    -rwxr-xr-x 1 root root 31234664 Oct 2 16:19 libpython3.12.so.1.0*
    -rwxr-xr-x 1 root root 15088 Oct 3 13:42 libpython3.so*
    drwxr-xr-x 2 root root 4096 Oct 3 13:42 pkgconfig/
    drwxr-xr-x 39 root root 4096 Oct 3 13:42 python3.11/
    drwxr-xr-x 40 root root 4096 Oct 2 16:19 python3.12/


    The default environment variable LD_LIBRARY_PATH is empty.

    Other:

    > readelf -d /usr/local/bin/python3.12

    Dynamic section at offset 0x2db8 contains 28 entries:
    0x0000000000000001 (NEEDED) Shared library: [libpython3.12.so.1.0]
    0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
    0x000000000000000c (INIT) 0x1000
    0x000000000000000d (FINI) 0x115c
    0x0000000000000019 (INIT_ARRAY) 0x3da8
    0x000000000000001b (INIT_ARRAYSZ) 8 (bytes)
    0x000000000000001a (FINI_ARRAY) 0x3db0
    0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
    0x000000006ffffef5 (GNU_HASH) 0x3b0
    0x0000000000000005 (STRTAB) 0x548
    0x0000000000000006 (SYMTAB) 0x3f8
    0x000000000000000a (STRSZ) 222 (bytes)
    0x000000000000000b (SYMENT) 24 (bytes)
    0x0000000000000015 (DEBUG) 0x0
    0x0000000000000003 (PLTGOT) 0x3fb8
    0x0000000000000002 (PLTRELSZ) 24 (bytes)
    0x0000000000000014 (PLTREL) RELA
    0x0000000000000017 (JMPREL) 0x738
    0x0000000000000007 (RELA) 0x678
    0x0000000000000008 (RELASZ) 192 (bytes)
    0x0000000000000009 (RELAENT) 24 (bytes)
    0x000000000000001e (FLAGS) BIND_NOW
    0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
    0x000000006ffffffe (VERNEED) 0x648
    0x000000006fffffff (VERNEEDNUM) 1
    0x000000006ffffff0 (VERSYM) 0x626
    0x000000006ffffff9 (RELACOUNT) 3
    0x0000000000000000 (NULL) 0x0


    readelf -d /usr/local/bin/python3.11

    Dynamic section at offset 0x2db8 contains 28 entries:
    0x0000000000000001 (NEEDED) Shared library:[libpython3.11.so.1.0]
    0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
    0x000000000000000c (INIT) 0x1000
    0x000000000000000d (FINI) 0x115c
    0x0000000000000019 (INIT_ARRAY) 0x3da8
    0x000000000000001b (INIT_ARRAYSZ) 8 (bytes)
    0x000000000000001a (FINI_ARRAY) 0x3db0
    0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
    0x000000006ffffef5 (GNU_HASH) 0x3b0
    0x0000000000000005 (STRTAB) 0x548
    0x0000000000000006 (SYMTAB) 0x3f8
    0x000000000000000a (STRSZ) 222 (bytes)
    0x000000000000000b (SYMENT) 24 (bytes)
    0x0000000000000015 (DEBUG) 0x0
    0x0000000000000003 (PLTGOT) 0x3fb8
    0x0000000000000002 (PLTRELSZ) 24 (bytes)
    0x0000000000000014 (PLTREL) RELA
    0x0000000000000017 (JMPREL) 0x738
    0x0000000000000007 (RELA) 0x678
    0x0000000000000008 (RELASZ) 192 (bytes)
    0x0000000000000009 (RELAENT) 24 (bytes)
    0x000000000000001e (FLAGS) BIND_NOW
    0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
    0x000000006ffffffe (VERNEED) 0x648
    0x000000006fffffff (VERNEEDNUM) 1
    0x000000006ffffff0 (VERSYM) 0x626
    0x000000006ffffff9 (RELACOUNT) 3
    0x0000000000000000 (NULL) 0x0

    Continue reading...

Compartilhe esta Página