0

I have both python 3.5.2 and 3.6.6

:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux

:~$ python3.6
Python 3.6.6 (default, Jun 28 2018, 04:42:43) 
[GCC 5.4.0 20160609] on linux

How can make changes, so that, typing python3 itself will be 3.6.6 version. ? can anybody help

Bhimasen
  • 677
  • 3
  • 8
  • 19
  • 1
    https://stackoverflow.com/questions/19256127/two-versions-of-python-on-linux-how-to-make-2-7-the-default - have you viewed this question? – boandriy Sep 06 '18 at 07:08
  • https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux – Brown Bear Sep 06 '18 at 07:08
  • 2
    I recommend using virtualenv to manage the development environment. – Heaven Sep 06 '18 at 07:10

2 Answers2

2

Assuing your python executable is located at /usr/bin/python3.6 You can set a shall alias:

alias python3=/usr/bin/python3.6

If you want this to ALWAYS be the default, you can set it in your ~/.bashrc

echo "alias python3=/usr/bin/python3.6" >> ~/.bashrc

Alternatively, the better option is to use a virtualenv for each different project, and not temper with the system default python. If you use virtualenvwrapper, you can create a new virtualenv and specify its default python executable by:

mkvirtualenv -p <PYTHON_PATH> <VIRTUALENV_NAME>
Victor Wong
  • 3,457
  • 1
  • 18
  • 31
0

set the python3 link to the correct executable

depending on where your python link and executable are located (e.g. /usr/bin/)

user@linux:/usr/bin$ ll python3
lrwxrwxrwx 1 root root 9 May 23 01:37 python3 -> python3.6*

easy way to find the links & executables

echo $PATH
aminator
  • 396
  • 7
  • 18