0

I'm using both conda and pyenv and would like to switch between both while staying in the same terminal.

The entries to initialize both in my .bashrc look as follows:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/myUser/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/myUser/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/home/myUser/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/myUser/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup

and

# Pyenv initialize
export PATH="/home/myUser/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

I simply tried to put the initialization lines (for pyenv) in a separate shell script, however it does not work (pyenv doesn't get initialized).

Info: Pyenv is yet another virtual python environment which I need for usage in combination with poetry

1 Answer 1

0

I seem to have found at least a work around. It seems that deactivating pyenv once it is activated is a hard thing to do so instead I define a init function in my .bashrc as suggested in this post

enable-pyenv () {
    # Load pyenv automatically by adding
    # the following to your profile:

    export PATH="$HOME/.pyenv/bin:$PATH"
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
}

Then I simply activate pyenv in every shell on demand. Note that the bash script I tried was not working (probably as it opens a separate shell session).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .