question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Activating an environment fails because running powershell scripts is disabled by default on Windows

See original GitHub issue

Environment 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:

  1. Fresh install of windows
  2. install python
  3. create virtual environment
  4. try to activate it in VS Code

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:41
  • Comments:68 (18 by maintainers)

github_iconTop GitHub Comments

330reactions
d3r3kkcommented, Sep 12, 2018

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:

Set-ExecutionPolicy RemoteSigned

And hit enter, respond y to any prompts that appear.

76reactions
dlechcommented, Mar 31, 2019

I was able to work around this problem by adding the following to my VS Code settings:

"terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"]
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found