CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘

问题描述

用 conda 创建了一个新环境,无法激活,报错信息如下。

$ conda activate env_name

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - cmd.exe
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

原因分析

脚本执行策略受限。

解决方案

以管理身份运行 Windows 终端,执行 set-ExecutionPolicy RemoteSigned 命令,然后输入 Y(是)。

PS C:\Windows\system32> set-ExecutionPolicy RemoteSigned

执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y)  [A] 全是(A)  [N] 否(N)  [L] 全否(L)  [S] 暂停(S)  [?] 帮助 (默认值为“N”): Y

引用参考

https://blog.csdn.net/qq_42951560/article/details/123859735

你可能感兴趣的:(windows,qa,windows,conda)