Powershell 尽管更新了ExecutionPolicy,但无法在VSCode中激活虚拟环境

Powershell 尽管更新了ExecutionPolicy,但无法在VSCode中激活虚拟环境,powershell,visual-studio-code,python-venv,executionpolicy,Powershell,Visual Studio Code,Python Venv,Executionpolicy,我正在尝试用VSCode建立一个虚拟环境 为此,我在GitBash中使用-m venv newproject创建了一个文件夹“newproject” 问题是我无法激活虚拟环境,因为正在运行脚本 在此系统上被禁用(以下代码来自VSCode终端): 我发现这让人困惑,因为我曾尝试通过Powershell将执行策略设置为admin,将其设置为RemoteSigned和Unrestricted,但仍然出现错误(下面的代码来自Powershell): 为什么即使允许运行本地编写的脚本,我仍然会收到错误 谢

我正在尝试用VSCode建立一个虚拟环境

为此,我在GitBash中使用
-m venv newproject
创建了一个文件夹“newproject”

问题是我无法激活虚拟环境,因为正在运行脚本 在此系统上被禁用(以下代码来自VSCode终端):

我发现这让人困惑,因为我曾尝试通过Powershell将执行策略设置为admin,将其设置为RemoteSigned和Unrestricted,但仍然出现错误(下面的代码来自Powershell):

为什么即使允许运行本地编写的脚本,我仍然会收到错误

谢谢大家!

我刚想出来。 必须允许在VSCode中而不是在单独的PowerShell窗口中使用脚本:

PS C:\Users\name\OneDrive\Dokumente\py_scripts\newproject\Scripts> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
PS C:\Users\name\OneDrive\Dokumente\py_scripts\newproject\Scripts> ./activate
(newproject) PS C:\Users\mikes\OneDrive\Dokumente\py_scripts\newproject\Scripts> 

您是否已安装virtualenv?是的,“newproject”文件夹中创建了所有文件:
name@DESKTOP-EIQBST8 MINGW64~/OneDrive/Dokumente/py_scripts/newproject$dir Include Lib scripts pyvenv.cfg
PS C:\windows\system32> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
PS C:\windows\system32> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process    RemoteSigned
  CurrentUser       Undefined
 LocalMachine       Undefined


PS C:\windows\system32> Set-ExecutionPolicy Unrestricted -Scope Process

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
PS C:\windows\system32> Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process    Unrestricted
  CurrentUser       Undefined
 LocalMachine       Undefined
PS C:\Users\name\OneDrive\Dokumente\py_scripts\newproject\Scripts> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
PS C:\Users\name\OneDrive\Dokumente\py_scripts\newproject\Scripts> ./activate
(newproject) PS C:\Users\mikes\OneDrive\Dokumente\py_scripts\newproject\Scripts>