简体   繁体   中英

Powershell doesn't running scripts even after setting execution policy

I am trying to run virtualenv script to activate it on powershell using:

.\env\Scripts\activate.ps1

but I get this error:

.\env\Scripts\activate.ps1 : File C:\Users\user\Desktop\tranning\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:1
+ .\env\Scripts\activate.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

I read this article and I tried to solve this by running powershell as administrator and type this command:

Set-ExecutionPolicy RemoteSigned 

but unfortunately nothing change

According to this earlier asked question there are a few other things you can try: PowerShell says "execution of scripts is disabled on this system."

To summarize from the link:

  1. If you are running from a windows server make sure you set the execution policy on all versions of powershell that you have on the system(both x64 x86 versions of powershell)

OR

  1. Run the following to bypass the Execution Policy:

powershell -ExecutionPolicy ByPass -File script.ps1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM