Python multi-version switching problem under ubuntu

        Under normal circumstances, the ubunu system will come with python. If you install other versions of python, there will be multiple versions of python. Therefore, if you want to switch between different versions under the ubuntu terminal, you need to set your default python version. Here is a demonstration of switching from Anaconda Python 2.7.13 version to python 2.7.12 version that comes with ubuntu 16.04LTS version. The specific reference steps are as follows: (The specific operation of the reader shall prevail)

(1) First check your default python version under the terminal, mine is Anaconda Python 2.7.13 version .

~$ python

         

(2) View all your python installation paths

~$ whereis python

        

(3) Select the python version you want to switch (there can be multiple), and then add it to the optional list. The first thing to add is the python 2.7.12 version that comes with the ubuntu 16.04LTS version. My path is /usr/ bin/python and /usr/bin/python2.7, note that there is a python between the two, the last number represents the priority, which is set to 1. (requires sudo privileges)

~$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

       

         Then add Anaconda Python2.7.13 version, the code is as follows, you need to change your path.

~$ sudo update-alternatives --install /home/rongsong/anaconda2/bin/python python /home/rongsong/anaconda2/bin/python2.7 2

         

   (4) Then look at the python version of your optional list, which we just added.

~$ update-alternatives --list python

                 

(5) Change your python version priority order

~$ update-alternatives --config python

        

        

            

(5) Finally, enter python in the ubuntu terminal, you can see that the current version is the python 2.7.12 version that comes with the ubuntu 16.04LTS version .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326305454&siteId=291194637