on Ubuntu 14.04 has python-3, python-2.7 and python is linked to python-2.7 by default. I have to run python-3 code on ubuntu -14.04. Can I modify /usr/bin/python link to python3? Any idea?
Thanks
on Ubuntu 14.04 has python-3, python-2.7 and python is linked to python-2.7 by default. I have to run python-3 code on ubuntu -14.04. Can I modify /usr/bin/python link to python3? Any idea?
Thanks
Don't do that.
A lot of things will (probably) break if you change the default python interpreter to python3.
The switch is not a simple one --- although by 16.04 I think that all the system scripts will be python3, it will probably not switched even then (thanks @florian-deisch). Other distros, like Arch, did the switch, but I am not sure if this is a good thing, given that there is a PEP explicitly suggesting the contrary...
Simply use
#!/usr/bin/env python3
as the "shebang" line (first line) of the scripts that you want to be run by python3.
/usr/bin/python
will still not point to python3 in 16.04 as recommended by PEP 0394
– Florian Diesch
Nov 12 '15 at 17:03
for the time being, all distributions should ensure that python refers to the same target as python2 .
– gertvdijk
Nov 12 '15 at 17:04
sudo update-alternatives --list python
If multiple versions are listed, you cen set which one to use withsudo update-alternatives --set python
– Charles Green Nov 12 '15 at 16:33