How to activate my environment in linux automatically using .bashrc

Question:

I would like to activate the environment that I created in Anaconda (myenv) automatically when linux server is opened. The myenv environment path is located in ‘/anaconda_env/personal/myenv’. I used the following command lines in .bashrc to automatically activate myenv. However, "base" environment is always activated instead of "myenv".

Can you help me correct my mistake in following command lines in order to automatically activate ‘myenv’ environment instead of ‘base’ environment?

Thanks.

export http_proxy=http://server-ip:port
export https_proxy=http://server-ip:port
export no_proxy="localhost,svc,node1"
export PATH=$PATH:/opt/miniconda/bin
alias envactivate="source activate /anaconda_env/personal/myenv"
alias spython="/anaconda_env/personal/myenv/bin/python"

## >>> conda initialize >>>
## !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/anaconda_env/miniconda/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"

if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/anaconda_env/miniconda/etc/profile.d/conda.sh" ]; then
        . "/anaconda_env/miniconda/etc/profile.d/conda.sh"
    else
        export PATH="/anaconda_env/miniconda/bin:$PATH"

    fi
fi
unset __conda_setup
# <<< conda initialize <<<

Asked By: Susan

||

Answers:

Try adding the following after last line in .bashrc

conda activate /anaconda_env/personal/myenv

Answered By: Gurdyal
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.