django – How to switch Python versions in Terminal?
django – How to switch Python versions in Terminal?
The simplest way would be to add an alias to python3
to always point to the native python
installed. Add this line to the .bash_profile
file in your $HOME
directory at the last,
alias python=python3
Doing so makes the changes to be reflected on every interactive shell opened.
As Inian suggested, you should alias python to point to python 3. It is very easy to do, and very easy to switchback, personally i have an alias setup for p2=python2 and p3=python3 as well to save on keystrokes.
Read here for more information: How do I create a Bash alias?
Here is an example of doing so for python:
alias python=python3
Like so:
$ python --version
Python 2.7.6
$ python3 --version
Python 3.4.3
$ alias python=python3
$ python --version
Python 3.4.3
See here for the original:
https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3
django – How to switch Python versions in Terminal?
You can just specify the python version when running a program:
for python 2:
python filename.py
for python 3:
python3 filename.py