0

I used anaconda3 for a python3 install. And now it's my default python:

$ which python
/home/xy/anaconda3/bin/python
$ which python3
/home/xy/anaconda3/bin/python

But I need python2 as my default python.

$ which python2
/usr/bin/python2

I tried to edit my .bashrc shown below,

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

By change the line of export PATH... to

export PATH="$PATH:/home/xy/anaconda3/bin"

It didn't change anything.

How should I set python2 back as the default?

2
  • 2
    Obligatory: pythonclock.org Commented May 19, 2020 at 15:42
  • 1
    I am not happy with the comments here: IMO, this can be solved cleanly, by using conda init <shell>, removing anaconda3/bin from PATH and setting ´conda config --set auto_activate_base False`. Commented May 19, 2020 at 15:53

1 Answer 1

1

I think the cleanest way to go forward is to do following changes:

1) Edit your ~/.bashrc and do following modifications

Keep this block. Do not edit it. If you already deleted it, you can recreate it by typing conda init bash.

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

2) Make sure you /home/xy/anaconda3/bin is not added to PATH outside of this block. If so, delete those.

3) Call conda config --set auto_activate_base False in your shell

From now on, you have to activate the anaconda environment manually with conda activate base. If you do not call this, you will default back to your system python.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.