Reputation: 336
I am using Ubuntu 19.10 and I have installed anaconda. Whenever I open terminal the base environment gets activated by default. I have another environment called kf which I actually use so every time I open terminal I have to conda activate kf. Is there a way so that I can set conda to activate kf environment by default when I open terminal?
Upvotes: 7
Views: 12165
Reputation: 422
I found a solution based on this answer from @asmeurer. It's especially useful if you want all the users enter the same env when a new terminal is initiated.
which conda
, e.g. /usr/local/anaconda3
;mkdir -p /usr/local/anaconda3/etc/conda/activate.d
;default_env.sh
in this folder. the filename is irrelevant; the content of the file is a one-liner: conda activate kf
.Upvotes: -1
Reputation: 168
Put your conda env name in file like: `.conda-env in root of your project
Edit your ~/.bashrc or ~/.zshrc :
# auto activate conda env
FILE=./.conda-env
if [[ -f "$FILE" ]]; then
CONDA_ENV=$(<$FILE)
conda activate $CONDA_ENV
fi
Upvotes: 0
Reputation: 76950
Conda doesn't have a way to set this, AFAIK, but you can easily accomplish it with some editing of .bashrc
(or whatever the initialization file is for your shell). Simply add
conda activate kf
to the bottom of your .bashrc
(e.g., echo "conda activate kf" >> ~/.bashrc
). Also, you might as well disable the auto-activation of base:
conda config --set auto_activate_base false
Upvotes: 7