Conda가 기본 환경을 기본적으로 활성화하지 못하도록하려면 어떻게해야합니까?
최근에 Mac에 anaconda2를 설치했습니다. 기본적으로 Conda는 새 터미널 세션을 열 때 기본 환경을 활성화하도록 구성되어 있습니다.
Conda 명령에 대한 액세스를 원합니다 (즉, Conda가 초기화 될 때 수행하는 $ PATH에 Conda 경로를 추가하여 괜찮습니다).
그러나 나는 보통 파이썬으로 프로그래밍하지 않으며 Conda가 기본적으로 환경을 활성화하는 것을 원하지 않습니다.
conda init프롬프트에서 처음 실행할 때 Conda는 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 환경을 활성화 할 수 없습니다.
다음을 제외하고 전체 블록을 주석 처리하려고했습니다.
export PATH="/Users/geoff/anaconda2/bin:$PATH"
그러나 새 세션을 시작하고 환경을 활성화하려고 할 때 다음 오류 메시지가 나타납니다.
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
이 질문 (및 이와 유사한 다른 질문 )은 도움이되지만 궁극적으로 내 질문에 대한 답변은 아니며 Linux 사용자에게 더 적합합니다.
설명을 위해, 나는를 제거하라는 게 아니에요 (base)내에서 $PS1내가 터미널 세션을 열 때 내가 활성화 기본으로하지 CONDA을 요구하고있다.
conda에 의해 추가 된 유사한 코드 블록이있는 conda 4.6이 있습니다. 제 경우에는 자동 기본 활성화를 비활성화하는 conda 구성 설정이 있습니다.
conda config --set auto_activate_base false
처음 실행 ./condarc하면 기본값을 재정의하는 해당 설정으로 홈 디렉토리 에을 생성합니다 .
이것은 당신의 혼란을 제거 .bash_profile하지는 않지만 conda가 관리하는 섹션을 수동으로 편집하지 않고도 더 깨끗한 솔루션입니다.
The answer depends a little bit on the version of conda that you have installed. For versions of conda >= 4.4, it should be enough to deactivate the conda environment after the initialization, so add
conda deactivate
right underneath
# <<< conda initialize <<<
So in the end I found that if I commented out the Conda initialisation block like so:
# >>> 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 <<<
It works exactly how I want. That is, Conda is available to activate an environment if I want, but doesn't activate by default.
There're 3 ways to achieve this after conda 4.6. (The last method has the highest priority.)
Use sub-command
conda configto change the setting.conda config --set auto_activate_base falseIn fact, the former
conda configsub-command is changing configuration file.condarc. We can modify.condarcdirectly. Add following content into.condarcunder your home directory,# auto_activate_base (bool) # Automatically activate the base environment during shell # initialization. for `conda init` auto_activate_base: falseSet environment variable
CONDA_AUTO_ACTIVATE_BASEin the shell's init file. (.bashrcfor bash,.zshrcfor zsh)CONDA_AUTO_ACTIVATE_BASE=falseTo convert from the
condarcfile-based configuration parameter name to the environment variable parameter name, make the name all uppercase and prependCONDA_. For example, conda’salways_yesconfiguration parameter can be specified using aCONDA_ALWAYS_YESenvironment variable.The environment settings take precedence over corresponding settings in
.condarcfile.
References
- The Conda Configuration Engine for Power Users
- Using the .condarc conda configuration file
conda config --describe- Conda 4.6 Release
This might be a bug of the recent anaconda. What works for me:
step1: vim /anaconda/bin/activate, it shows:
#!/bin/sh
_CONDA_ROOT="/anaconda"
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
\. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
conda activate "$@"
step2: comment out the last line: # conda activate "$@"
To disable auto activation of conda base environment in terminal:
conda config --set auto_activate_base false
To activate conda base environment:
conda activate
'Programing' 카테고리의 다른 글
| int가 null인지 확인하는 방법 (0) | 2020.08.25 |
|---|---|
| 디렉티브 테스트에서 $ apply 대 $ digest (0) | 2020.08.25 |
| Ruby에서 주석 차단 (0) | 2020.08.25 |
| ImportError : Windows에 site라는 모듈이 없습니다. (0) | 2020.08.25 |
| 원격 연결을 위해 redis 포트 열기 (0) | 2020.08.25 |