diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-10-27-22-23-57.gh-issue-125873.BG97KU.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-10-27-22-23-57.gh-issue-125873.BG97KU.rst new file mode 100644 index 00000000000000..fc4818781ee132 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2024-10-27-22-23-57.gh-issue-125873.BG97KU.rst @@ -0,0 +1 @@ +Improved error message when an environment variable is misconfigured. diff --git a/Python/codecs.c b/Python/codecs.c index 8a4d99bdd924fa..c9802af937296e 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -1693,7 +1693,9 @@ _PyCodec_InitRegistry(PyInterpreterState *interp) if (mod == NULL) { PyThreadState *tstate = _PyThreadState_GET(); _Py_DumpPathConfig(tstate); - return PyStatus_Error("Failed to import encodings module"); + return PyStatus_Error("Failed to import encodings module. " + "Your environment probably has misconfigured variables! " + "Please check PYTHONHOME otherwise refer to `--help-env`"); } Py_DECREF(mod);