As you've noted, pyvenv
/the venv
module doesn't ship with activate_this.py
. But if you need this feature, you can borrow activate_this.py
from virtualenv
, put it in the expected location (virtualenv_path/bin/activate_this.py
), then use it. It seems to work fine. Only issue is that the virtualenv
docs are out of date for Python 3 (they claim you use execfile
, which doesn't exist). The Python 3 compatible alternative would be:
activator = 'some/path/to/activate_this.py' # Looted from virtualenv; should not require modification, since it's defined relatively
with open(activator) as f:
exec(f.read(), {'__file__': activator})
Nothing activate_this.py
does is magical, so you could manually perform the same changes without looting from virtualenv
(adjusting PATH
, sys.path
, sys.prefix
, etc.), but borrowing makes it much simpler in this case.