Unable to debug - libpython2.7.so.1.0 missing under Ubuntu 24.04 LTS

Am encountering the following error when attempting to debug an AZ_delivery board using an ESP-prog board with a clean install of both MS Code and PlatformIO. Previously, this setup has worked flawlessly but I haven’t done any ESP32 debugging for a while so I can’t confirm the previous libraries used etc.

The main.cpp code compiles fine but the PIO debug fails to start debugging. On switching to the debug console, the following error is present (username obfuscated for security):

undefined/home/----/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gdb: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

This behaviour is exhibited with both the DEB release of MS Code and the Flatpak. Ubuntu is currently on Python 3.x and does not support the installation of earlier Python libraries globally.

I am using the following platformio.ini settings:

[env:az-delivery-devkit-v4]
platform = espressif32
board = az-delivery-devkit-v4
framework = arduino
monitor_speed = 115200
debug_tool = esp-prog
upload_protocol = esp-prog
debug_init_break = tbreak setup
debug_speed = 1000
build_type = debug
debug_build_flags = -O0 -g -ggdb

Is this error message just a red-herring or is my platformio.ini file incorrect?

I think no red herring and your platformio.ini looks fine for me and IMHO can’t be the origin of the error - it comes from your OS.

Using file and ldd on my system (an openSUSE Leap) shows me that

file ~/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gdb
~/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gdb: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), **dynamically linked**, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=a5169bbb9fb2bae5c9fe959aa6b3f81a53485573, stripped

and

ldd ~/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gdb
        linux-vdso.so.1 (0x00007ffef559b000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f4a4b86b000)
        libpython2.7.so.1.0 => /usr/lib64/libpython2.7.so.1.0 (0x00007f4a4b620000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4a4b5fc000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00007f4a4b5f8000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f4a4b4ac000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f4a4b265000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f4a4b241000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f4a4b04a000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f4a4b8b2000)

AFAIR I installed the needed lib manually (years ago :wink:)

May be you can follow the instructions described in this post on ubuntuforums to solve your problem

There is an open, unresolved issue on https://github.com/platformio/platform-espressif32/

Thank you both. Unfortunately, until this bug is patched I have had to resort to running MS Code + Platformio in a VM, currently with an earlier version of Ubuntu 22.04. Not ideal as 22.04 still has a few months to go until end of life, fingers crossed they won’t take them out the repository before the bug is squashed!

Having waited in vain for this to be resolved, I have found the current workaround works with Debian 12:

Install Python 2.7 in parallel with Python 3.x

And all the securityflaws contained in a software that is abandoned since January 1st, 2020 :wink:

In the meantime I’ve found another workaround by installing newer versions of the needed toolchains - Debug aborts with python error - #3 by arduhe

If it’s fixed in newer toolchain versions, you can also use the https://github.com/pioarduino/platform-espressif32 project to use a newer Arduino-ESP32 core and its toolchains as a whole.

[env:esp32dev]
; Arduino-ESP32 3.0.5
platform = https://github.com/pioarduino/platform-espressif32/releases/download/51.03.05/platform-espressif32.zip
board = esp32dev
framework = arduino

This gives

PACKAGES:
 - framework-arduinoespressif32 @ 3.0.5
 - framework-arduinoespressif32-libs @ 5.1.0+sha.33fbade6b8
 - tool-esptoolpy @ 4.7.5
 - tool-mklittlefs @ 3.2.0
 - tool-riscv32-esp-elf-gdb @ 11.2.0+20220823
 - tool-xtensa-esp-elf-gdb @ 11.2.0+20230208
 - toolchain-xtensa-esp32 @ 12.2.0+20230208
1 Like

Thank you arduhe and maxgerhardt. For whatever reason my Code/PIO install hasn’t picked this up for whatever reason despite being upgraded regularly.

Totally agree with the security implications, so I removed the earlier Python version and upgraded Code/PIO. No joy, debug crashes with:

undefined Could not find platform independent libraries
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to [:<exec_prefix>]
ImportError: No module named site

This despite a clean vanilla install of Code/PIO on Debian 12. Am I missing something here or is the toolchain not automatically updated? AFAIK I do not explicitly declare a specific version for my projects.

Replacing the elderly and obsolete python cures this.

Solved - just delete the .pio folder under the project folder. There should be a matching .code one as well, but you don’t need to touch this.

Rebuild and the project debugs successfully.