用powershell执行conda其他指令是可以的,唯独执行activate指令,想打开虚拟环境时,发现并未打开。
此时可执行指令
conda init powershell
找到profile.ps1文件是否在"C:\Users\你的用户名\Documents\WindowsPowerShell\"这个路径下,不是的话请拷贝到这个路径下,并重启powershell。
如果重启之后发现powershell出现报错
Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows
. : 无法加载文件 C:\Users\xxx\Documents\WindowsPowerShell\profile.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参
阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 3
+ . 'C:\Users\xxx\Documents\WindowsPowerShell\profile.ps1'
则需要修改策略
1.输入
get-ExecutionPolicy
输出Restricted
,即脚本执行策略受限2.换脚本执行策略:
set-ExecutionPolicy RemoteSigned
,然后输入Y
3.更换完成后,再次使用命令
get-ExecutionPolicy
查看脚本执行策略。输出RemoteSigned,即更改成功。4.再次重启,即可成功。