[Distutils] Module Installation Issues

Paul Moore p.f.moore at gmail.com
Wed Sep 14 11:31:17 EDT 2016

On 13 September 2016 at 23:55, Donald Stufft <donald at stufft.io> wrote:
> Perhaps a better idea would be to add some smarts to the REPL (but not to Python itself) that would detect something like:
>>>> pip install
> And print a better error message that gives a better indication about what’s gone wrong besides a SyntaxError?

This is pretty easy to do:

def excepthook(typ, value, traceback):
    # Tidy this up to suit
    if typ is SyntaxError and value.text.startswith("pip"):
        print("You may want to run this from a shell prompt")
    sys.__excepthook__(typ, value, traceback)

sys.excepthook = excepthook

Of course, it doesn't solve the problem of a user who doesn't know
what a "shell prompt" is...


More information about the Distutils-SIG mailing list