How To Switch Back And Forth Between (general) Pyenv Python And System Python In Ubuntu?
I used to work with python installed under anaconda3 in my Ubuntu. But for some reason, I needed to also create a pyenv and generalize it for all users. To run python scripts, I le
Solution 1:
Try adding this to your .bashrc.
export ANACONDA_HOME="/home/username/anaconda3"alias my_anaconda="unset PYENV_HOME && export PATH=$ANACONDA_HOME/bin:$PATH"# Load pyenv automatically by adding# the following to ~/.bash_profile:export PYENV_HOME="/home/username/.pyenv/"alias my_pyenv='unset ANACONDA_HOME && export PATH=$PYENV_HOME/bin:$PATH && eval "$(pyenv init -)" && eval "$(pyenv virtualenv-init -)"'
On shell, try:
$ my_anaconda
$ my_pyenv
Solution 2:
Inspired by answers, thank you. I have used a similar approach on MacOs:
# in my ~/.bash_profile# Anaconda app is installed and initiated at the terminal start# path to Anaconda: /Users/<USER>/opt/anaconda3/switch_pyenv(){
conda deactivate
conda deactivate # in case you're not in base enveval"$(pyenv init -)"eval"$(pyenv virtualenv-init -)"
}
switch_conda(){
conda activate base
export PATH="/Users/<USER>/opt/anaconda3/bin:$PATH"
}
# quick check which python, pipw(){
which python
which pip
py -V
}
When I switch to an environment, I check 'where am i' with the shorthand w
.
Post a Comment for "How To Switch Back And Forth Between (general) Pyenv Python And System Python In Ubuntu?"