Skip to content

Instantly share code, notes, and snippets.

@tilgovi
Created March 29, 2012 16:40
Show Gist options
  • Select an option

  • Save tilgovi/2239638 to your computer and use it in GitHub Desktop.

Select an option

Save tilgovi/2239638 to your computer and use it in GitHub Desktop.
virtualenv lifting
"""
If a virtual environment is active, make sure it's being used.
Globally-installed console scripts use an absolute shebang path which
prevents them from importing packages in the virtualenv.
"""
import os
import os.path
if 'VIRTUAL_ENV' in os.environ:
env = os.environ['VIRTUAL_ENV']
activate = os.path.join(env, 'bin', 'activate_this.py')
execfile(activate, dict(__file__=activate))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment