My problem is almost identical to this question. However the solutions don't work when I use tmux. Usually I first open a terminal (bash) and then start a tmux session.
When I then try to use this solution:
in my ~/.bashrc
I add
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('$HOME/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]; then
. "$HOME/miniconda3/etc/profile.d/conda.sh"
else
export PATH="$HOME/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
# Here comes the code to switch between conda and pyenv:
switch_pyenv(){
conda deactivate
conda deactivate # in case you're not in base env
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
}
switch_conda(){
conda activate base
export PATH="$HOME/miniconda3/bin:$PATH"
}
# quick check which python, pip
w(){
which python
which pip
python --version
}
However whenever I open tmux, the switching fails with the error message:
_pyenv_virtualenv_hook: command not found