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.
7 Answers
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
6 Comments
ln: failed to create symbolic link '/usr/bin/python3.6': File existsln to work: ln -s /usr/bin/python3.6 /usr/bin/python3python3 pointing at Python 3.5.3 and not Python 3.6.1. Not sure what, though.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 python3You 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
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
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
Method 1:
pip install virtualenv virtualenv name_of_projectMethod 2
py -3 -m venv name_of_project
sudo apt-get install python3.6