我安装的conda为miniconda,安装在E:\miniconda下
首先 在powershell中输入
powershell -ExecutionPolicy ByPass -NoExit -Command "& 'E:\miniconda\shell\condabin\conda-hook.ps1' ; conda activate 'E:\miniconda' "
这时候,当前的powershell应该已经正确activate conda environment
再输入
conda init powershell
重启powershell,默认情况下应该会出错,因为powershell默认的策略组是restricted,不允许运行脚本。目前主流的策略是RemoteSigned,即本地脚本无需签名,互联网脚本需要签名运行
设置当前用户策略为RemoteSigned
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
重启powershell,此时应该能自动激活conda环境