Page 1 of 1

debugging on ubuntu linux -- how to compile/install python2.7 properly

Posted: Tue Nov 14, 2023 12:07 am
by qubdtq
I'm a beginner, but I thought I would share this in case it helps anyone else that is searching for this info --

I could not start the debugger for my ESP32 board (ESP32-DevKitC-VIE) in VSCode/Platform IO -- I got an error in the debug console. If I directly run ~/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gdb, I get an error saying that python2.7.so.1.0 can not be found:
/home/myusername/.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
Apparently this is because python2.7 is required, but it is not installed. There are no python2 packages in the Ubuntu repositories anymore, so the standard advice of "apt-get install python2.7-dev" does not work.

After hours of working on this, I came to this procedure:

- download .tgz from https://www.python.org/downloads/release/python-2718/
- untar, enter python directory

Code: Select all

./configure --enable-shared --enable-unicode=ucs4
(I can't do --enable-optimizations because it fails with an error for some reason when it is doing the tests)

Code: Select all

make -j8
sudo make -j8 altinstall
(-j8 for an 8-core machine)

--enable-unicode is necessary to prevent the error "symbol lookup error: /home/myusername/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gdb: undefined symbol: PyUnicodeUCS4_FromEncodedObject"

--enable-optimizations is usually recommended, but the tests that it triggers would cause the make to hang forever with an error.

After doing that, the xtensa-esp32-elf-gdb command runs OK. I'm not 100% sure this is all proper and that there will be no problems, but it seems OK so far.

Re: debugging on ubuntu linux -- how to compile/install python2.7 properly

Posted: Tue Oct 29, 2024 9:07 pm
by herbiejay
After trying to sort this out for way too long in Ubuntu 24.04, using VS Code, I was able to get debugging functioning with an esp32-s3 by installing the libpython3-all-dev and libpython3-all-dbg packages.

Re: debugging on ubuntu linux -- how to compile/install python2.7 properly

Posted: Wed Oct 30, 2024 2:51 am
by qubdtq
Nice -- were you having the same issue as described above? Did you try the above solution? (Your method is obviously superior; just curious.)

Re: debugging on ubuntu linux -- how to compile/install python2.7 properly

Posted: Fri Nov 15, 2024 6:49 pm
by herbiejay
I got the above method to work but I really didn't want to have to have python2 installed on my system if I could avoid it to keep things clean and prevent other software from trying to use it.