3

I did everything from these answers on a previous thread and nothing changed. Even uninstalling Python did not improve the situation. Everything was working fine but all of a sudden it stopped working.

    Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = 'C:\\iverilog\\gtkwave\\bin\\python.exe'
  sys.base_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.base_exec_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.executable = 'C:\\iverilog\\gtkwave\\bin\\python.exe'
  sys.prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.exec_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.path = [
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python38.zip',
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.8',
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.8',
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\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 0x000029e8 (most recent call first):
<no Python frame>
ti7
  • 16,375
  • 6
  • 40
  • 68
uljad1000
  • 31
  • 2

1 Answers1

0

I've just had the same problem.

Looking back, the error is fairly clear: ModuleNotFoundError: No module named 'encodings' means Python is not able to find the encodings module, one of Python built-in modules. I had a look at my filesystem and found out that the encodings module is found at C:\msys64\mingw64\lib\python3.8\encodings. This meant that Python could not find that folder!

My simple solution was to add C:\msys64\mingw64\lib\python3.8 to the PYTHONPATH environment variable. On Windows you can either set it from the Windows settings UI - the permanent way - or set it temporarily from the command line, using this command: set PYTHONPATH=C:\msys64\mingw64\lib\python3.8\.

This kind of feels like a hack since, as a basic Python module, it should be found automatically and yet doesn't. However, at this point, I've had no other Python-related problems so I figure it really does the trick.

SolarBear
  • 4,534
  • 4
  • 37
  • 53