Activating an environment fails because running powershell scripts is disabled by default on Windows
See original GitHub issueEnvironment data
- VS Code version: 1.27.1 (user setup)
- Extension version (available under the Extensions sidebar): 2018.8.0
- OS and version: Windows 10
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.7…0
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
- Relevant/affected Python packages and their versions: N/A
Actual behavior
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
Expected behavior
I don’t need need to disable running scripts in able to use VS code
Steps to reproduce:
- Fresh install of windows
- install python
- create virtual environment
- try to activate it in VS Code
Issue Analytics
- State:
- Created 5 years ago
- Reactions:41
- Comments:68 (18 by maintainers)
Top Results From Across the Web
Solution to “Running Scripts Is Disabled On This System” Error ...
This error happens because the venv\Scripts\activate command tries to run the Activate.ps1 PowerShell script to activate the virtual environment ...
Read more >Windows error: "activate.ps1 cannot be loaded because ...
From the Windows Start Menu, open a PowerShell window. · Execute the following command in that window: Set-ExecutionPolicy -Scope CurrentUser - ...
Read more >Fix for PowerShell Script cannot be loaded because running ...
This is due to the Windows PowerShell execution policy being set to prevent untrusted scripts which can affect your Windows client environment.
Read more >Activating virtual environment throws error in powershell
In PowerShell on Windows, script execution is disabled by default. Enable it with Set-ExecutionPolicy . There are 3 scopes; more specific ones ...
Read more >PowerShell - Running scripts is disabled on this system
The PowerShell execution policy is default set to Restricted. You can change the PowerShell execution policies with Set-ExecutionPolicy cmdlet.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hmmm… this feels like it might be a VSCode problem.
To fix the issue, you can simply open a Powershell window as administrator and type the following:
And hit enter, respond
y
to any prompts that appear.I was able to work around this problem by adding the following to my VS Code settings: