0

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
mcExchange
  • 6,154
  • 12
  • 57
  • 103
  • Maybe search around for tmux and conda problems. I recall seeing tmux messes with PATH in a way that interferes with how Conda manipulates it. – merv May 07 '21 at 15:04
  • the error message rather refers to a problem with pyenv than with conda though ... – mcExchange May 20 '21 at 12:45

0 Answers0