用vscode打开terminal时报错. : 无法加载文件 C:\Users\alex\Documents\WindowsPowerShell\profile.ps1
: 无法加载文件 C:\Users\xxx\Documents\WindowsPowerShell\profile.ps1,因为在。此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?ID=135170 中的 about_Execution_Policies。在命令行执行: Get-ExecutionPolicy -List。所在位置 行:1
一、背景说明
用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,不报错了
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)