用vscode打开terminal时报错. : 无法加载文件 C:\Users\alex\Documents\WindowsPowerShell\profile.ps1
一、背景说明
用vscode开发python项目时,刚安装好环境,创建好了虚拟环境,重新打开个terminal窗口时,就报这个错:
. : 无法加载文件 C:\Users\xxx\Documents\WindowsPowerShell\profile.ps1,因为在
此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?Link
ID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 3
+ . 'C:\Users\xxx\Documents\WindowsPowerShell\profile.ps1'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
二、解决方案
在命令行执行: Get-ExecutionPolicy -List
会出现:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined
然后执行:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned -Force
再执行查看命令:
Get-ExecutionPolicy -List
会看到结果如下:
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine Undefined
再次重新打开新的terminal,不报错了
更多推荐
所有评论(0)