[issue27054] Python installation problem: No module named 'encodings'

STINNER Victor report at bugs.python.org
Thu Apr 9 11:57:25 EDT 2020


STINNER Victor <vstinner at python.org> added the comment:

> I continually get the error
> "Fatal Python error: Py_Initialize: unable to load the file system codec
> ImportError: No module named 'encodings'"

FYI I enhanced this error in Python 3.8 to "dump the Python path configuration". Example:

$ PYTHONHOME=x PYTHONPATH=y python3.8
Python path configuration:
  PYTHONHOME = 'x'
  PYTHONPATH = 'y'
  program name = 'python3.8'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3.8'
  sys.base_prefix = 'x'
  sys.base_exec_prefix = 'x'
  sys.executable = '/usr/bin/python3.8'
  sys.prefix = 'x'
  sys.exec_prefix = 'x'
  sys.path = [
    'y',
    'x/lib64/python38.zip',
    'x/lib64/python3.8',
    'x/lib64/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 0x00007f50aaad8740 (most recent call first):
<no Python frame>

It should be easier for users to understand their mistake.

In general, leave PYTHONHOME empty/unset unless you understand very well what you are doing ;-)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue27054>
_______________________________________


More information about the Python-bugs-list mailing list