powershell 启动时报错 profile.ps1 cannot be loaded because running scri

时间:2025-03-24 13:48:19

powershell启动时报错,但是仍然可以启动

  • 出错问题
  • 解决方式

出错问题

powershell启动时,见到报这种错误:

File C:\Users\xxxx(我的名字,这里先打码了)\Documents\WindowsPowerShell\profile.ps1 cannot be loaded because running scripts is disabled on this system.

这时候虽然powershell可以启动起来,但是在跑python脚本时,或者启动conda环境时,仍然会出问题。所以这个东西需要解决。

解决方式

  1. 以admin方式运行powershell一次,从win->powershell->run as admin.
  2. set-ExecutionPolicy RemoteSigned

其实这件事情并不经常发生的,大家不用太担心。原因其实就是powershell的一个execution mode的问题,这样做的结果就能让你运行Python或者启动conda activate,如果你还想还原回去的话,就用:

set-ExecutionPolicy Restricted

不得不说,windows真神奇,推荐大家使用Linux。。。。