Skip to content

Instantly share code, notes, and snippets.

@Answeror
Created October 4, 2012 08:02
Show Gist options
  • Save Answeror/3832085 to your computer and use it in GitHub Desktop.
Save Answeror/3832085 to your computer and use it in GitHub Desktop.
Activate virtualenv in blender
def activate_virtualenv(name):
"""Activate given virtualenv.
Virtualenv home folder is given by environment variable ``WORKON_HOME`` or
``~/Envs`.
"""
if 'WORKON_HOME' in os.environ:
home = os.environ['WORKON_HOME']
else:
home = os.path.expanduser(os.path.join('~', 'Envs'))
filepath = os.path.join(home, name, 'Scripts', 'activate_this.py')
with open(filepath, 'r') as f:
exec(f.read(), dict(__file__=filepath))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment