-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Show a better error message when PYTHONHOME is wrong #125873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think the most reasonable fix would be to change this line to something like: return PyStatus_Error("Failed to import encodings module. Are you sure PYTHONHOME is correct?"); PR welcome! |
You can also damage
|
You could, but what makes |
Tangentially related: we should also fail earlier if |
Related to GH-125873, where this failure mode is triggered by specifying a bad |
Signed-off-by: Filipe Laíns <[email protected]>
Signed-off-by: Filipe Laíns <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Feature or enhancement
Proposal:
Currently, when
PYTHONHOME
is wrong, python saysModuleNotFoundError: No module named 'encodings'
. This is error makes it sound like a module is missing, when it's actually a part of the core interpreter configuration that is broken, which the error doesn't tell.Ideally, the error would show if a
pyvenv.cfg
was loaded, as a wronghome
path causes this error.Example pyenv Python 3.12 on Ubuntu 24.04:
Example python-build-standalone on Ubuntu 24.04:
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
There are several bug reports featuring this error: https://github.com/python/cpython/issues?q=is%3Aissue+%22ModuleNotFoundError%3A+No+module+named+%27encodings%27%22+
https://stackoverflow.com/questions/38132755/importerror-no-module-named-encodings
The error is occurring for users in various communities: https://www.google.com/search?q=%22ModuleNotFoundError%3A+No+module+named+%27encodings%27%22
Linked PRs
The text was updated successfully, but these errors were encountered: