Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VirtualEnvs (venv) and Powershell

36 views
Skip to first unread message

Carl Caulkett

unread,
Mar 31, 2017, 8:04:09 PM3/31/17
to
Hello everyone,

I've just started to investigate VirtualEnvironments as a means of
preventing my 3rd party code becoming chaotic. I've discovered that
venv's can be managed quite effectively using Powershell. When
Activate.ps1 is run, the PowerShell changes to indicate that the venv
is active which is nice. However despite the official documention,
there doesn't seem to be a corresponding Deactivate.ps1. There is a
deactivate.bat but that doesn't appear to switch the paths back to
their pre-env state.
What I would really like is a Git-Bash based alternative to
Powershell to manage my Virtual Environments. Has anyone dicovered
tools or techniques to achieve this?

Thanks for any response

--
Carl

Cameron Simpson

unread,
Apr 1, 2017, 6:33:31 PM4/1/17
to
Well, in a UNIX environment the natural things is simply to start a shell using
the target venv. Thus:

sh -c '. /path/to/the/venv/bin/activate; exec $SHELL'

or even simpler:

( . /path/to/the/venv/bin/activate; exec $SHELL )

That would get you a prompt using the virtualenv by default. To reset to the
old settings, exit that subshell.

Maybe I misunderstand your needs.

Cheers,
Cameron Simpson <c...@zip.com.au>

eryk sun

unread,
Apr 1, 2017, 7:46:55 PM4/1/17
to
On Sat, Apr 1, 2017 at 12:03 AM, Carl Caulkett <carl.c...@gmail.com> wrote:
> I've just started to investigate VirtualEnvironments as a means of
> preventing my 3rd party code becoming chaotic. I've discovered that
> venv's can be managed quite effectively using Powershell. When
> Activate.ps1 is run, the PowerShell changes to indicate that the venv
> is active which is nice. However despite the official documention,
> there doesn't seem to be a corresponding Deactivate.ps1. There is a
> deactivate.bat but that doesn't appear to switch the paths back to
> their pre-env state.

Please read the contents of Activate.ps1. The way the `deactivate`
function works should be obvious.
0 new messages