This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Fatal Python error on Fedora linux for arm-none-eabi-gdb

I am running latest Fedora linux and I see this error -

 λ arm-none-eabi-gdb --version  
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/usr/local/bld-tools/bld-tools-virtual-env/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/local/bld-tools/bld-tools-virtual-env/bin/python'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.executable = '/usr/local/bld-tools/bld-tools-virtual-env/bin/python'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/python3.8/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f6b9daeec00 (most recent call first):
<no Python frame>

I have tried setting my PYTHONHOME=/usr/lib:/usr/lib64 and that did not work. I have python versions from 3.6 to 3.11. I tried the toolchain v 12.2 and v11.3 -both have same issue.

λ ls -lart /usr/lib/python3.?
/usr/lib/python3.6:
total 0
drwxr-xr-x. 1 root root  22 Dec  9 22:54 site-packages
drwxr-xr-x. 1 root root  26 Dec  9 22:54 .
dr-xr-xr-x. 1 root root 898 Dec  9 22:55 ..

/usr/lib/python3.7:
total 0
drwxr-xr-x. 1 root root  26 Dec  9 22:54 .
drwxr-xr-x. 1 root root  22 Dec  9 22:54 site-packages
dr-xr-xr-x. 1 root root 898 Dec  9 22:55 ..

/usr/lib/python3.9:
total 0
drwxr-xr-x. 1 root root  22 Dec  9 22:55 site-packages
dr-xr-xr-x. 1 root root 898 Dec  9 22:55 ..
drwxr-xr-x. 1 root root  26 Dec  9 22:55 .

/usr/lib/python3.8:
total 4
drwxr-xr-x. 1 root root  22 Dec  9 20:23 site-packages
dr-xr-xr-x. 1 root root 898 Dec  9 22:55 ..
lrwxrwxrwx. 1 root root  32 Dec  9 23:35 lib-dynload -> /usr/lib64/python3.8/lib-dynload
drwxr-xr-x. 1 root root  48 Dec  9 23:35 .

PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/opt/gcc-arm-none-eabi/arm-gnu-toolchain-12.2.mpacbti-bet1-x86_64-arm-none-eabi/bin/:/opt/gcc-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin

One thing that looks weird to me is that sys.executable = '/usr/local/bld-tools/bld-tools-virtual-env/bin/python'

I checked and this path does not exist. Not sure why it thinks that this is the executable

λ /usr/local/bld-tools/bld-tools-virtual-env/bin/python --version
zsh: no such file or directory: /usr/local/bld-tools/bld-tools-virtual-env/bin/python

  • A workaround might be to install python3.8 and set PYTHONPATH and PYTHONHOME accordingly:

    1. dnf install python3.8
    2. export PYTHONPATH=/usr/lib64/python3.8 && export PYTHONHOME=/usr/bin/python.3.8

    arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb --version
    GNU gdb (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.1.90.20221210-git
    Copyright (C) 2022 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <gnu.org/.../gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.