{"record":{"id":"3f7ab8865cff16cd","repo":"python/cpython","slug":"s","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"Modules/getpath.c","lineNumber":594,"sourceCode":"    {\"isxfile\", getpath_isxfile, METH_VARARGS, NULL},\n    {\"joinpath\", getpath_joinpath, METH_VARARGS, NULL},\n    {\"readlines\", getpath_readlines, METH_VARARGS, NULL},\n    {\"realpath\", getpath_realpath, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL}\n};\n\n\n/* Two implementations of warn() to use depending on whether warnings\n   are enabled or not. */\n\nstatic PyObject *\ngetpath_warn(PyObject *Py_UNUSED(self), PyObject *args)\n{\n    PyObject *msgobj;\n    if (!PyArg_ParseTuple(args, \"U\", &msgobj)) {\n        return NULL;\n    }\n    fprintf(stderr, \"%s\\n\", PyUnicode_AsUTF8(msgobj));\n    Py_RETURN_NONE;\n}\n\n\nstatic PyObject *\ngetpath_nowarn(PyObject *Py_UNUSED(self), PyObject *args)\n{\n    Py_RETURN_NONE;\n}\n\n\nstatic PyMethodDef getpath_warn_method = {\"warn\", getpath_warn, METH_VARARGS, NULL};\nstatic PyMethodDef getpath_nowarn_method = {\"warn\", getpath_nowarn, METH_VARARGS, NULL};\n\n/* Add the helper functions to the dict */\nstatic int\nfuncs_to_dict(PyObject *dict, int warnings)\n{","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/python/cpython/blob/bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6/Modules/getpath.c#L576-L612","documentation":"This is the getpath module's warn() implementation: a Python-level warning string forwarded to C stderr by the frozen getpath code that locates the interpreter's home/prefix at startup. The '%s' is just the printf placeholder — the actual message is whatever getpath passed (e.g. 'Could not find platform independent libraries', 'Consider setting $PYTHONHOME...', prefix warnings). Seeing it means path detection during startup had to complain.","triggerScenarios":"Interpreter startup where the calculated prefix/exec_prefix does not match the build-time expectations, PYTHONHOME is wrong, or the stdlib zip/libdir cannot be found — getpath raises warnings via sys.warn (this function when warnings are enabled).","commonSituations":"Moving or copying a CPython installation to another directory without setting PYTHONHOME; broken virtualenvs/pyenv shims pointing at a deleted prefix; Linux distributions relocating binaries; embedded interprements with misconfigured search paths. Python may still start but import of stdlib can misbehave.","solutions":["Set PYTHONHOME to the correct prefix (the dir containing lib/pythonX.Y) or unset a stale one","Reinstall the Python build in a location matching its configured prefix, or rebuild with ./configure --prefix matching the install dir","For embedded interpreters, configure the home via PyConfig.home / path config before initialization","Check for leftover PYTHONHOME/PYTHONPATH env vars from virtualenvs or containers layered onto the image"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# shell: verify the install layout before relying on it\n# test -x \"$PYTHONHOME/bin/python3\" || echo 'PYTHONHOME is wrong'\n# env | grep -E 'PYTHON(HOME|PATH)'   # find stale vars","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set PYTHONHOME only when the interpreter was relocated, and point it at the real prefix","Unset PYTHONHOME/PYTHONPATH from old virtualenvs when switching interpreters","Rebuild relocated Pythons with --prefix matching their final install directory","Validate deployment images by launching `python3 -c 'import sys; print(sys.prefix)'` and comparing to expectation"],"tags":["startup","getpath","cpython","environment","pythonhome"],"backgroundTag":null,"analyzedSha":"bc6749cc3b5ae4a5e88a6cc2d5b3bebbe354eae6","analyzedAt":"2026-08-14T22:01:13.976Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}