Ask questionsActivating an environment fails because running powershell scripts is disabled by default on Windows
Create python terminal results in a powershell error
PS C:\dev\loadtest> & c:/dev/loadtest/env/Scripts/activate.ps1 & : File C:\dev\loadtest\env\Scripts\activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + & c:/dev/loadtest/env/Scripts/activate.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) , PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
I don't need need to disable running scripts in able to use VS code
Answer questions DonJayamanne
Not sure whether we've explored this. Here's what I tried and it works, basically bypass the restriction temporarily, then restore it (applies only to current session):
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process ; & ./venv/scripts/activate.ps1 ; Set-ExecutionPolicy -ExecutionPolicy Default -Scope Process
prompt(yes/no) using the
-Confirmflag, giving the user more control.
Set-ExecutionPolicy -Confirm -ExecutionPolicy Unrestricted -Scope Process ; & ./venv/scripts/activate.ps1 ; Set-ExecutionPolicy -ExecutionPolicy Default -Scope Process
Unrestricedwill result in a prompt being displayed to user for downloaded scripts - i.e. letting user decide - I think thats a good thing).
Finally: I tried and works on a vanilla Windows 10 setup (had to install one today to test something else).
Restrictedbefore and after the above scripts are executed