Fork me on GitHub

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

问题描述

  • 使用 conda activate 激活虚拟环境时报错:
conda activate virtual_env
  • 提示内容
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - 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'.

原因

  • 提示内容已经给出原因,当前使用的 shell 没有配置好 conda activate,需要运行 conda init 初始化 shell
  • 一般使用 zsh shell 时,首次激活 conda 虚拟环境时会遇到

解决方法

  • 方法一:根据提示运行 conda init ,重启 shell 后即可正常使用 conda activate 激活虚拟环境的指令
# 如使用 zsh,则
conda init zsh
# 如果使用 bash,则
conda init bash
  • 方法二:首次激活 conda 虚拟环境,可用 source activate 激活(如下),以后就可以正常使用 conda activate 激活虚拟环境了
# 首次使用 source activate 命令激活虚拟环境 my_conda_virutal_environment
source activate my_conda_virutal_environment
# 退出虚拟环境
conda deactivate
# 以后使用 conda activate 命令激活虚拟环境
conda activate my_conda_virutal_environment

来源:https://blog.csdn.net/sdnuwjw/article/details/112448792
posted @   会自愈的哈士奇  阅读(206)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
点击右上角即可分享
微信分享提示