I just learned, that upon some errors, Python dumps its path configuration ; for instance, like in this snippet from Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding, when trying to start uwsgi :
!!! Python Home is not a directory: /home/env3/educ !!!
Set PythonHome to /home/env3/educ
Python path configuration:
PYTHONHOME = '/home/env3/educ'
PYTHONPATH = (not set)
program name = '/home/env3/educ/bin/python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/home/env3/educ/bin/python'
sys.base_prefix = '/home/env3/educ'
sys.base_exec_prefix = '/home/env3/educ'
sys.executable = '/home/env3/educ/bin/python'
sys.prefix = '/home/env3/educ'
sys.exec_prefix = '/home/env3/educ'
sys.path = [
'/home/env3/educ/lib/python38.zip',
'/home/env3/educ/lib/python3.8',
'/home/env3/educ/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 0x00007efe89db8780 (most recent call first):
<no Python frame>
So, now I'm wondering - is there a command line switch, so I could just call, let's say something like python --dump-path-config
, and it would print the above path configuration, and exit?
I am aware that one could write a Python script that would perform the same task and run that - however, since this dump is apparently "built-in" in Python anyways, I was wondering if there was a way to use that machinery.
( Btw, I found Issue 38236: Dump the Python path configuration at the first import error - Python tracker - apparently this kind of dump exists only for Python 3.8 and 3.9 )