54

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.

2
  • What do you mean with "downloaded"? Did you "installed" it? How? Commented May 2, 2017 at 17:05
  • sudo apt-get install python3.6 Commented May 2, 2017 at 17:09

7 Answers 7

102

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 
Sign up to request clarification or add additional context in comments.

6 Comments

ln: failed to create symbolic link '/usr/bin/python3.6': File exists
You need to swap the arguments for ln to work: ln -s /usr/bin/python3.6 /usr/bin/python3
sorry :/ <code> ln -s /usr/bin/python3.6 /usr/bin/python3</code>
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.
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.<br/> 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
|
10

Worked Perfectly...

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

Comments

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

Comments

4

first step

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

second step

vim .bashrc

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

Comments

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

Comments

0

It happened to me and after reading a lot, finally it worked running the following commands:

  • show the executable that will be run under the hood. pyenv which python3 pyenv which python

--> they showed different version 3.9.1 and 3.13.1

Finally I run the following commands:

pyenv shell 3.13.1 -- select just for current shell session pyenv local 3.13.1 -- automatically select whenever you are in the current directory (or its subdirectories) pyenv global 3.13.1 -- select globally for your user account

and finally... $ python3 --version Python 3.13.1

$ python --version Python 3.13.1

$pyenv which python /Users/molina/.pyenv/versions/3.13.1/bin/python

Now everything works!!

Comments

-1
  • Method 1:

    pip install virtualenv
    virtualenv name_of_project 
    
  • Method 2

    py -3 -m venv name_of_project
    

1 Comment

- pip install virtualenv * - virtualenv envname or py -3 -m venv name_of_project

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.