From 2fc28bcc0aa6939b8d58894b234c9192c93d7f9f Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Fri, 25 May 2018 17:42:06 +0900 Subject: [PATCH] Provide better error message for activate_this.py Ref #2257. --- pipenv/core.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pipenv/core.py b/pipenv/core.py index 75bc6276..3c40da4e 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -2226,6 +2226,14 @@ def do_shell(three=None, python=False, fancy=False, shell_args=None): def inline_activate_virtualenv(): try: activate_this = which('activate_this.py') + if not activate_this or not os.path.exists(activate_this): + click.echo( + u'{0}: activate_this.py not found. Your environment is most ' + u'certainly not activated. Continuing anyway…' + u''.format(crayons.red('Warning', bold=True)), + err=True, + ) + return with open(activate_this) as f: code = compile(f.read(), activate_this, 'exec') exec(code, dict(__file__=activate_this))