views:

188

answers:

2

Hi fellow pythonistas, there seems to be a problem when virtualenv is used in PowerShell.

When I try to activate my environment in PowerShell like..

> env/scripts/activate

.. nothing happens. (the shell prompt should have changed as well as the PATH env. variable .)

I guess the problem is that PowerShell spawns a new cmd. process just for running the activate.bat thus rendering the changes activate.bat does to the shell dead after it completes.

Do you have any workarounds for the issue? (I'm sticking with cmd.exe for now)

+5  A: 

Here's a post which contains a Powershell script which allows you to run batch files that persistently modify their environment variables. The script propagates any environment variable changes back to the calling PowerShell environment.

Vinay Sajip
Thank you Vinay, clearly explains the issue.
utku_karatas
A: 

A quick work-around would be to invoke cmd and then run your activate.bat from within the cmd session. For example:

PS C:\my_cool_env\Scripts> cmd
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\my_cool_env\Scripts>activate.bat
(my_cool_env) C:\my_cool_env\Scripts>
elliott