[PYTHON] Fatal Python error: exceptions bootstrapping error. Aborted

Hi,

On L4T24.1 ( userspace 64 bit) when I compiled a python program using cython and aarch64-linux-gnu-gcc to C executable it is failing with the error.

Fatal Python error: exceptions bootstrapping error. 
Aborted

Here is the strace log:

newfstatat(AT_FDCWD, "/home/lib/python2.7/lib-dynload", 0x7ff58e7780, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/lib/python2.7/lib-dynload", {st_mode=S_IFDIR|0755, st_size=12288, ...}, 0) = 0
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7893d000
munmap(0x7f7893d000, 262144)            = 0
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7893d000
munmap(0x7f7893d000, 262144)            = 0
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7893d000
write(2, "Fatal Python error: exceptions b"..., 52Fatal Python error: exceptions bootstrapping error.
) = 52
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
tgkill(16140, 16140, SIGABRT)           = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=16140, si_uid=1000} ---
+++ killed by SIGABRT +++
Aborted

When I googled i saw some issue on Mac with builtins component not available. I tried is by installing pip install future but no success.

DO i need to compile the python from source?
Any pointer. Thanks in advance.

Did a grep and found that in Python-2.7.6/Objects/exceptions.c the below code is throwing it

#define PRE_INIT(TYPE) if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \
    Py_FatalError("exceptions bootstrapping error.");
bltinmod = PyImport_ImportModule("__builtin__");
    if (bltinmod == NULL)
        Py_FatalError("exceptions bootstrapping error.");
    bdict = PyModule_GetDict(bltinmod);
    if (bdict == NULL)
        Py_FatalError("exceptions bootstrapping error.");

After gdb debugging getting below error:

Fatal Python error: exceptions bootstrapping error.

Program received signal SIGABRT, Aborted.
0x0000007fb7b8daf8 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.

Hello,
I tried cython (based on http://stackoverflow.com/questions/5105482/compile-main-python-program-using-cython, and it seems OK). List my commands for your reference.

  1. cat hello.py
    print(“Hello World!”)
  2. sudo apt install cython3
  3. cython3 --embed -o hello.c hello.py
  4. gcc -Os -I /usr/include/python3.5 -o hello hello.c -lpython3.5m -lpthread -lm -lutil -ldl
  5. ./hello
    Hello World!

br
ChenJian