How do I switch back to python2 after Anaconda set python3 as the default?

Piyush Deshmukh

Recently, I installed Anaconda3-2.5.0-Linux-x86_64.sh on my 15.04 and ended up with this!

:~$ python --version
Python 3.5.1 :: Anaconda 2.5.0 (64-bit)

:~$ python2 --version
Python 2.7.9

:~$ python3 --version
Python 3.5.1 :: Anaconda 2.5.0 (64-bit)

During the last moments of installation, I did enter something as yes in hurry, and I suppose it had to do something with this. (Ok, my fault, I should have handled that carefully, but I need help now, not criticism).

Screenshot

AFAIK this is definitely going to break other programs. What do I do now?


What I think could work.

Can this be done using aliases?

alias python=python2

But I ain't sure.

Nephente

I went through the installation in a VM, and the following happend.

  1. The installer asks for an install location. Default is /home/myuser/anaconda3.
  2. At the end you'll be asked

    Python 3.5.1 :: Continuum Analytics, Inc.
    creating default environment...
    installation finished.
    Do you wish the installer to prepend the Anaconda3 install location
    to PATH in your /home/myuser/.bashrc ? [yes|no]
    [no] >>> yes
    
    Prepending PATH=/home/myuser/anaconda3/bin to PATH in /home/myuser/.bashrc
    A backup will be made to: /home/myuser/.bashrc-anaconda3.bak
    

To restore the old behavior, go to your home directory and do

mv .bashrc-anaconda3.bak .bashrc

then start a new shell.

As you suggest, you could alias python=python2, but I find that a bit weird. I would

  1. Restore the original .bashrc
  2. Create (if it does not exist) ~/bin
  3. Link ln -s ~/anaconda3/bin/python3 ~/bin/python3
  4. [Prepend $HOME/bin to $PATH](Should already be set by default by ~/.profile)
  5. Relogin.

That way, calling python3 will start the one from Anaconda.


An important point is, that the original /usr/bin/python is still there, and still points to python2.7. The ramifications of having python->python3 in your path depend on how a specific script is called.

If the shebang #!/usr/bin/python is used, like it probably is in all executables that ship with Ubuntu, nothing will change. On the other hand, for better portability #!/usr/bin/env python is sometimes used, which will now cause python3.5 to be called.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I switch back to python2 after Anaconda set python3 as the default?

From Dev

How do I switch from Python2 to Python3 in Sublime Text

From Dev

How do I set Anaconda's python as my default python command?

From Dev

How do I get /usr/bin/python3 back after deleting it?

From Dev

How do I make Python3 the default Python in Geany

From Dev

how do i convert my supervisord configuration from python2 to python3?

From Dev

Python: set python2 as the default after installing python 3 with anacoda3

From Java

How do I set PyCharm font back to default size?

From Dev

How do I set the panel whitelist back to the default?

From Dev

How do I drop back to the python shell after exiting a script?

From Dev

How do I drop back to the python shell after exiting a script?

From Dev

How do I get Anaconda3 to see Python 2.7 after installing it?

From Dev

How do I tell snapcraft to run my code as python2 not python3 when using the new python plugin?

From Dev

How do I switch between 2 windows forms back and forth

From Dev

How do I set IDLE as the default editor for Python scripts?

From Dev

How do I set IDLE as the default editor for Python scripts?

From Dev

How do I set default brightness after boot?

From Dev

How can I set up ubuntu to switch back to English after a few minutes of inactivity?

From Dev

How to switch between python2 and python3 pip on Fedora 22?

From Dev

How do I switch back to windows booting up after installing Mavericks?

From Dev

How do I set Windows Boot Manager back to its default path?

From Dev

How do I get back the default Ubuntu fonts after installing wine?

From Dev

How do I revert back to default values in HTML/DOM after triggering an event(jQuery)?

From Dev

Why do I have problems loading a module in Python3 but not in Python2?

From Dev

How can I make the "python" command in terminal, run python3 instead of python2?

From Dev

how to set different PYTHONPATH variables for python3 and python2 respectively

From Dev

python3: how do i format 2 as 02

From Dev

Anaconda - I have set up an environment, how do I use it?

From Dev

Python 3: List of over 100 indices cycles back around after index 47. why? how do I stop this?

Related Related

  1. 1

    How do I switch back to python2 after Anaconda set python3 as the default?

  2. 2

    How do I switch from Python2 to Python3 in Sublime Text

  3. 3

    How do I set Anaconda's python as my default python command?

  4. 4

    How do I get /usr/bin/python3 back after deleting it?

  5. 5

    How do I make Python3 the default Python in Geany

  6. 6

    how do i convert my supervisord configuration from python2 to python3?

  7. 7

    Python: set python2 as the default after installing python 3 with anacoda3

  8. 8

    How do I set PyCharm font back to default size?

  9. 9

    How do I set the panel whitelist back to the default?

  10. 10

    How do I drop back to the python shell after exiting a script?

  11. 11

    How do I drop back to the python shell after exiting a script?

  12. 12

    How do I get Anaconda3 to see Python 2.7 after installing it?

  13. 13

    How do I tell snapcraft to run my code as python2 not python3 when using the new python plugin?

  14. 14

    How do I switch between 2 windows forms back and forth

  15. 15

    How do I set IDLE as the default editor for Python scripts?

  16. 16

    How do I set IDLE as the default editor for Python scripts?

  17. 17

    How do I set default brightness after boot?

  18. 18

    How can I set up ubuntu to switch back to English after a few minutes of inactivity?

  19. 19

    How to switch between python2 and python3 pip on Fedora 22?

  20. 20

    How do I switch back to windows booting up after installing Mavericks?

  21. 21

    How do I set Windows Boot Manager back to its default path?

  22. 22

    How do I get back the default Ubuntu fonts after installing wine?

  23. 23

    How do I revert back to default values in HTML/DOM after triggering an event(jQuery)?

  24. 24

    Why do I have problems loading a module in Python3 but not in Python2?

  25. 25

    How can I make the "python" command in terminal, run python3 instead of python2?

  26. 26

    how to set different PYTHONPATH variables for python3 and python2 respectively

  27. 27

    python3: how do i format 2 as 02

  28. 28

    Anaconda - I have set up an environment, how do I use it?

  29. 29

    Python 3: List of over 100 indices cycles back around after index 47. why? how do I stop this?

HotTag

Archive