How do I replace python2 with py3 in my gnome terminal? Would
alias python='python3'
work? Thanks!
How do I replace python2 with py3 in my gnome terminal? Would
alias python='python3'
work? Thanks!
There is no need to replace Python. Use
python
for Python 2 and
python3
for Python 3 when calling your script.
As others have mentioned, changing python to point to python3 system-wide could cause troubles and is probably not a good idea. However, if you only really want this behavior for a certain project, you could consider using pyenv to set what python means within a particular directory. It's not in the repos, but it's relatively straightforward to set up following the github page. Once you have pyenv installed and setup,
pyenv versions
will list the python versions you have installed. Then to set python to point to the system's python3 only for the local directory (see doc), you can use
pyenv local 3.5.2
(assuming 16.04, or whatever python3 appears in the output of the pyenv versions command).
Note, virtualenv which is in the repos can also be used to similar effect. See a comparison here.