I need to combine two different parts in .bashrc My purpose is to initialize PYTHONPATH as empty before try to initialize conda.
In .bashrc, there is conda initialize part.
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/me/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/me/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/me/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/me/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
But, I have trouble with default PYTHONPATH because I couldn't touch this default except when I want to use conda. So, I create conda() alias. But it comes into conflict with using conda initialize part.
An error message is showed like below.
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
This means conda initialize was not executed.
Here is conda().
state=true
conda() {
if $state; then
state=false
PYTHONPATH=''
command conda "$@"
else
command conda "$@"
fi
}
The .basrh should behavior like once I try to use conda statement on the command line, clearing PYTHONPATH only for the first time before conda initialize works. PYTHONPATH should be untouchable if I'm not trying to use conda statement.