3

I am using Windows PowerShell. But, I don't know why, when I try to activate a python virtual environment, I get this error:

venv\Scripts\activate : File C:\Users\Dell\Desktop\flask\microblog\venv\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:1
+ venv\Scripts\activate
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

This is the command I ran:

venv\Scripts\activate

This is the first time it has happened. What is the problem?

1
  • In PowerShell on Windows, script execution is disabled by default. Enable it with Set-ExecutionPolicy. There are 3 scopes; more specific ones have higher precedence: -Scope LocalMachine (requires admin rights), -Scope CurrentUser, or -Scope Process (current process only). The PowerShell CLI accepts a process-specific -ExecutionPolicy <policy> too . Execution policies can also be set via GPO, in which case they cannot be changed or overridden with Set-ExecutionPolicy or via the CLI. Commented Nov 18, 2020 at 15:53

1 Answer 1

5

Looks like running powershell scripts is disabled on your machine. you can run as admin:

Set-ExecutionPolicy RemoteSigned

or

Set-ExecutionPolicy Unrestricted

this should solve the problem

Sign up to request clarification or add additional context in comments.

1 Comment

That works, but you don't necessarily need admin privileges, namely if you use -Scope CurrentUser. Conversely, if the execution policy is set via GPO (Group Policy Objects), it can't be changed with Set-ExecutionPolicy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.