Merge pull request #2263 from pypa/better-activate-this-error

Provide better error message for activate_this.py
This commit is contained in:
Dan Ryan
2018-06-03 21:13:00 -04:00
committed by GitHub
+8
View File
@@ -2241,6 +2241,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))