53

I just downloaded Python 3.6.1, but when I type python3 -V in the terminal it's still Python 3.5.3. How can I make python3 point to Python 3.6? All versions are in the /usr/bin/ directory.

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
ian-campbell
  • 1,605
  • 1
  • 20
  • 42

6 Answers6

96

do

rm /usr/bin/python3
ln -s /usr/bin/python3.6 /usr/bin/python3

much better solution:

Damn, Python is used throughout much of Ubuntu for system scripts and software, and software relies on having Python (and the commands to start Python) in a certain spot. do back then.

rm /usr/bin/python3 
ln -s /usr/bin/python3.5 /usr/bin/python3 

create alias in ~/.bash_aliases

alias python3='/usr/bin/python3.6' 

Scripts can then start with something like:

#!/usr/bin/env python3 
tso
  • 4,732
  • 2
  • 22
  • 32
  • 1
    `ln: failed to create symbolic link '/usr/bin/python3.6': File exists` – ian-campbell May 02 '17 at 17:14
  • You need to swap the arguments for `ln` to work: `ln -s /usr/bin/python3.6 /usr/bin/python3` – Laurent S May 02 '17 at 17:18
  • 1
    sorry :/ ln -s /usr/bin/python3.6 /usr/bin/python3 – tso May 02 '17 at 17:18
  • Correct, it worked with `ln -s /usr/bin/python3.6 /usr/bin/python3` – ian-campbell May 02 '17 at 17:18
  • 2
    This solution actually broke my Ubuntu terminal. Something in the background is/was depending on `python3` pointing at `Python 3.5.3` and not `Python 3.6.1`. Not sure what, though. – ian-campbell May 02 '17 at 21:38
  • 3
    Damn, Python is used throughout much of Ubuntu for system scripts and software, and software relies on having Python (and the commands to start Python) in a certain spot. do back then.
    `rm /usr/bin/python3` `ln -s /usr/bin/python3.5 /usr/bin/python3` create alias in ~/.bash_aliases `alias python3='/usr/bin/python3.6'` Scripts can then start with something like: `#!/usr/bin/env python3`
    – tso May 03 '17 at 06:00
9

Worked Perfectly...

ln -sf /usr/bin/python3.5 /usr/bin/python3
Deepak Sharma
  • 1,401
  • 19
  • 21
6

You could update the default python version system-wide using update-alternatives command.

$ sudo update-alternatives  --set python3 /usr/bin/python3.6

or you can also run the following command to choose among the various python versions installed on a host.

$ sudo update-alternatives --config python
Tushar Gautam
  • 458
  • 6
  • 19
3

If you are looking for other than the accepted answer. Here is the solution that saved my life. This is to replace it with new version.


$ python3 --version
  Python 3.5.2

$ ls -lh /usr/bin/python3
  lrwxrwxrwx 1 root root 9 Mar 23  2016 /usr/bin/python3 -> python3.5

$ sudo mv /usr/bin/python3 /usr/bin/_python3
$ sudo cp /usr/bin/python3.6 /usr/bin/python3

$ python3 --version
  Python 3.6.11

Masood
  • 121
  • 4
2

first step

ln -sf /usr/bin/python3.6 /usr/bin/python3

second step

vim .bashrc

alias python3='/usr/bin/python3.6'
Sajibe Kanti
  • 181
  • 1
  • 9
-1
  • Method 1:

    pip install virtualenv
    virtualenv name_of_project 
    
  • Method 2

    py -3 -m venv name_of_project
    
Vivek p.s
  • 1
  • 3