Title: Issue warning when the we can't find a valid standard library during path initialization · Issue #145273 · python/cpython · GitHub
Open Graph Title: Issue warning when the we can't find a valid standard library during path initialization · Issue #145273 · python/cpython
X Title: Issue warning when the we can't find a valid standard library during path initialization · Issue #145273 · python/cpython
Description: Feature or enhancement Proposal: Currently, if we don't find the standard library, we fail with an obscure message. $ PYTHONHOME=nonsense ./python -c 'print("foo!")' Fatal Python error: Failed to import encodings module Python runtime st...
Open Graph Description: Feature or enhancement Proposal: Currently, if we don't find the standard library, we fail with an obscure message. $ PYTHONHOME=nonsense ./python -c 'print("foo!")' Fatal Python error: Failed to i...
X Description: Feature or enhancement Proposal: Currently, if we don't find the standard library, we fail with an obscure message. $ PYTHONHOME=nonsense ./python -c 'print("foo!")' Fatal Pyt...
Opengraph URL: https://github.com/python/cpython/issues/145273
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Issue warning when the we can't find a valid standard library during path initialization","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nCurrently, if we don't find the standard library, we fail with an obscure message.\n\n```python\n$ PYTHONHOME=nonsense ./python -c 'print(\"foo!\")'\nFatal Python error: Failed to import encodings module\nPython runtime state: core initialized\nException ignored in the internal traceback machinery:\nModuleNotFoundError: No module named 'traceback'\nModuleNotFoundError: No module named 'encodings'\n\nStack (most recent call first):\n```\n\nThis is a common problem, as can be seen with a quick google search. One of the top results is a [nonsense AI slop blogpost](https://www.geeksforgeeks.org/python/resolve-no-module-named-encoding-in-python/).\n\nIt is generally caused or a misconfigured Python home directory, either by setting `PYTHONHOME`, or by broken virtual environments.\nIt would be helpful to show a warning if we are unable to find a valid standard library during initialization.\n\n```python\nWARN: Could not find the standard library directory! The Python 'home' directory was set to 'nonsense', is this correct?\nFatal Python error: Failed to import encodings module\nPython runtime state: core initialized\nException ignored in the internal traceback machinery:\nModuleNotFoundError: No module named 'traceback'\nModuleNotFoundError: No module named 'encodings'\n\nStack (most recent call first):\n```\n\nBad `._pth` files can also cause this.\n\n### Has this already been discussed elsewhere?\n\nNo response given\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-145274\n* gh-145437\n* gh-145442\n* gh-145544\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/FFY00","@type":"Person","name":"FFY00"},"datePublished":"2026-02-26T20:48:22Z","url":"https://github.com/python/cpython/issues/145273"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a160335d-9e6d-be87-c385-1558fc11b6b3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EB3E:2D40DE:3425111:425D271:6B021B33 |
| html-safe-nonce | aee26cb8460ab2fc0acae11806c2a2be4873e884b3594fcfbffc0eca75169e70 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjNFOjJENDBERTozNDI1MTExOjQyNUQyNzE6NkIwMjFCMzMiLCJ2aXNpdG9yX2lkIjoiMzMyMTE5MTMzNTgyNTkwNjQ4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 50dc830c8168abe1ab0666f55b4251ec52ec7dafd46bfeb22e6266e134b22016 |
| hovercard-subject-tag | issue:3997681078 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/145273/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d07161e32b3036261bbbced0e3aa41b49cd6ccb2fc226773a9a75f97a2b7b81a/python/cpython/issues/145273 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d07161e32b3036261bbbced0e3aa41b49cd6ccb2fc226773a9a75f97a2b7b81a/python/cpython/issues/145273 |
| og:image:alt | Feature or enhancement Proposal: Currently, if we don't find the standard library, we fail with an obscure message. $ PYTHONHOME=nonsense ./python -c 'print("foo!")' Fatal Python error: Failed to i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | FFY00 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width