默认情况下,如何防止Conda激活基本环境? [英] How do I prevent Conda from activating the base environment by default?

查看:566
本文介绍了默认情况下,如何防止Conda激活基本环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在Mac上安装了anaconda2.默认情况下,将Conda配置为在打开新的终端会话时激活基本环境.

I recently installed anaconda2 on my Mac. By default Conda is configured to activate the base environment when I open a fresh terminal session.

我想访问Conda命令(即,我想将Conda的路径添加到我的$ PATH中,Conda在初始化时会这样做,就可以了.)

I want access to the Conda commands (i.e. I want the path to Conda added to my $PATH which Conda does when initialised so that's fine).

但是我通常不使用python编程,并且我不希望Conda默认激活环境.

But I don't ordinarily program in python, and I don't want Conda to activate an environment by default.

第一次从提示符处执行conda init时,Conda将以下内容添加到我的.bash_profile中:

When first executing conda init from the prompt, Conda adds the following to my .bash_profile:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/geoff/anaconda2/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
if [ -f "/Users/geoff/anaconda2/etc/profile.d/conda.sh" ]; then
    . "/Users/geoff/anaconda2/etc/profile.d/conda.sh"
else
    export PATH="/Users/geoff/anaconda2/bin:$PATH"
fi
# fi
unset __conda_setup
# <<< conda initialize <<<

如果我注释掉整个块,那么我将无法激活任何Conda环境.

If I comment out the whole block, then I can't activate any Conda environments.

我试图注释掉整个区块,除了

I tried to comment out the whole block except for

export PATH="/Users/geoff/anaconda2/bin:$PATH"

但是当我开始一个新的会话并尝试激活一个环境时,我收到了以下错误消息:

But then when I started a new session and tried to activate an environment, I got this error message:

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

此问题(及其他这样)很有帮助,但最终并不能回答我的问题,更适合linux用户.

This question (and others like it) are helpful, but doesn't ultimately answer my question and is more suited for linux users.

为澄清起见,我不是要从我的$PS1中删除(base),而是要我在打开终端会话时不要激活Conda.

For clarification, I'm not asking to remove the (base) from my $PS1 I'm asking for Conda not to activate base when I open a terminal session.

推荐答案

我有conda 4.6,其中包含由conda添加的类似代码块.就我而言,有一个conda配置设置可禁用自动基本激活:

I have conda 4.6 with a similar block of code that was added by conda. In my case, there's a conda configuration setting to disable the automatic base activation:

conda config --set auto_activate_base false

首次运行它时,它将在主目录中创建一个./condarc,并使用该设置覆盖默认设置.

The first time you run it, it'll create a ./condarc in your home directory with that setting to override the default.

这不会使您的.bash_profile变得杂乱无章,但这是一个更干净的解决方案,无需手动编辑conda管理的部分.

This wouldn't de-clutter your .bash_profile but it's a cleaner solution without manual editing that section that conda manages.

这篇关于默认情况下,如何防止Conda激活基本环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆