-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-72327: Add help message for pip in REPL #8536
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
Changes from 1 commit
1e02cdb
49a8299
b762543
0784d5a
ab29fa1
5bb0a8d
239fd5d
2d302e6
ae30adf
2bb1e38
f9bb5c8
e092342
0e6d9e2
8122a6e
2cd4867
5034571
36c8256
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,14 +394,15 @@ def _register_detect_pip_usage_in_repl(): | |
old_excepthook = sys.excepthook | ||
|
||
def detect_pip_usage_in_repl(typ, value, traceback): | ||
old_excepthook(typ, value, traceback) | ||
if typ is SyntaxError and ( | ||
"pip install" in value.text or "pip3 install" in value.text | ||
): | ||
print("\nThe Python package manager (pip) can only be used from" | ||
" outside of Python.\nPlease try the `pip` command in a" | ||
" separate terminal or command prompt.", | ||
file=sys.stderr) | ||
value.msg = ("The Python package manager (pip) can only be used" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since there is a chance of false detection, it is worth to include the original message in the result. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original message is just
to something like the more expansive:
I'm happy with either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not always "invalid syntax".
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is why the original suggestion from ncoghlan has There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not always "invalid syntax" even if the type is SyntaxError.
Also I think that we perhaps can use |
||
" from outside of Python.\n" | ||
"Please try the `pip` command in a" | ||
" separate terminal or command prompt.") | ||
|
||
old_excepthook(typ, value, traceback) | ||
|
||
sys.excepthook = detect_pip_usage_in_repl | ||
serhiy-storchaka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.