1

I have installed python 3.6 in an Ubuntu 16.04 platform that had previously python 3.5

now if I check the installed version I have:

ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       9 Nov 24  2017 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root       9 Nov 24  2017 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3492656 Nov 12 19:46 /usr/bin/python2.7
lrwxrwxrwx 1 root root      33 Nov 12 19:46 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root      16 Nov 24  2017 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root       9 Mar 23  2016 /usr/bin/python3 -> python3.5
-rwxr-xr-x 2 root root 4464368 Nov 12 16:27 /usr/bin/python3.5
-rwxr-xr-x 2 root root 4464368 Nov 12 16:27 /usr/bin/python3.5m
-rwxr-xr-x 2 root root 4719712 Dec 25 04:54 /usr/bin/python3.6
-rwxr-xr-x 2 root root 4719712 Dec 25 04:54 /usr/bin/python3.6m
lrwxrwxrwx 1 root root      10 Mar 23  2016 /usr/bin/python3m -> python3.5m
lrwxrwxrwx 1 root root      16 Nov 24  2017 /usr/bin/python-config -> python2.7-config

However if I check the version that is running is:

python3 --version
Python 3.5.2

The same in the jupyter notebook

enter image description here

How can I set Python 3.6.7 as default instead of Python 3.5.2?

emax
  • 171
  • 1
  • 1
  • 6
  • Try sudo update-alternatives --config python3. – Jos May 09 '19 at 08:55
  • 2
    @Jos I would oppose updating alternatives because some packages strictly depends on Python 3.5 and updating alternatives can break things up. Need to look at some other workaround – Kulfy May 09 '19 at 09:01
  • You are right, but then it would have been slightly risky to install Python 3.6 in the first place. In this case, I suppose OP needs to use a full path to the 3.6.7 executable? – Jos May 09 '19 at 09:12
  • I agree with Kulfy, you should under no circumstances change what the system's python3 executable points to, that would break many applications. You can still manually run Python 3.6 with the command python3.6 instead of python3, or you can make a Bash alias like alias py='python3.6' if you want to save you some typing. – Byte Commander May 09 '19 at 09:25
  • @ByteCommander ... or use shebang? – Kulfy May 09 '19 at 09:29
  • 1
    @Jos Downloading and changing symlinks are two independent things. Downloading might not break things but symlinks can. Python3 is symlink to Python3.5 – Kulfy May 09 '19 at 09:31
  • @Kulfy the previous one was related to the installation that I did. But I will remove it. – emax May 09 '19 at 09:44
  • @ByteCommander I did not understand how to make it. Sorry I am not really familiar with it. – emax May 09 '19 at 09:46
  • @emax The post I linked above describes how to make an alias, among other things. Whether you want to make something for Python 3 instead of 2 or 3.6 instead of 3.5 is not much of a difference. Just remember not to touch the system's internal symlinks, only configure stuff for your user, like aliases (or just type out python3.6 if needed) – Byte Commander May 09 '19 at 09:50
  • @ByteCommander Hi, I saw it. Should I do alias python='/usr/bin/python3.6?' – emax May 09 '19 at 09:53
  • Whatever you want to type in your shell to open the 3.6 interpreter. Personally I'd use something completely different that doesn't shadow any existing names, like e.g. py36 instead. But that is your choice, as it is only an alias, it will not effect anything but your interactive shells. – Byte Commander May 09 '19 at 10:00
  • @ByteCommander the problem is how can it work on jupyter notebook? – emax May 09 '19 at 10:05
  • @emax see https://stackoverflow.com/q/28831854/4518341 – wjandrea May 09 '19 at 13:20

0 Answers0