Issue
How do I upgrade my python3 installation on Ubuntu? In particular, from 3.5.2 --> 3.6.x
Here's the basic attempt, though I have also tried remove
and purge
commands with no apparent effect.
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-130-generic x86_64)
$ ubuntu@ubuntu-xenial:/vagrant$ python3 --version
Python 3.5.2
$ sudo apt-get install python3 3.6 --reinstall
... [no errors, lots of output]
$ ubuntu@ubuntu-xenial:/vagrant$ python3 --version
Python 3.5.2
at this point I'd expected to see Python 3.6.x as the version. I don't see any new entries in /usr/bin
ubuntu@ubuntu-xenial:/vagrant$ ll /usr/bin | grep python
lrwxrwxrwx 1 root root 26 May 18 2016 dh_pypy -> ../share/dh-python/dh_pypy*
-rwxr-xr-x 1 root root 1056 Nov 24 2017 dh_python2*
lrwxrwxrwx 1 root root 29 May 18 2016 dh_python3 -> ../share/dh-python/dh_python3*
lrwxrwxrwx 1 root root 23 Dec 4 2017 pdb2.7 -> ../lib/python2.7/pdb.py*
lrwxrwxrwx 1 root root 23 Nov 28 2017 pdb3.5 -> ../lib/python3.5/pdb.py*
lrwxrwxrwx 1 root root 31 Mar 23 2016 py3versions -> ../share/python3/py3versions.py*
lrwxrwxrwx 1 root root 26 May 18 2016 pybuild -> ../share/dh-python/pybuild*
lrwxrwxrwx 1 root root 9 Nov 24 2017 python -> python2.7*
lrwxrwxrwx 1 root root 9 Nov 24 2017 python2 -> python2.7*
-rwxr-xr-x 1 root root 3492656 Dec 4 2017 python2.7*
lrwxrwxrwx 1 root root 9 Mar 23 2016 python3 -> python3.5*
-rwxr-xr-x 2 root root 4464400 Nov 28 2017 python3.5*
-rwxr-xr-x 2 root root 4464400 Nov 28 2017 python3.5m*
lrwxrwxrwx 1 root root 10 Mar 23 2016 python3m -> python3.5m*
lrwxrwxrwx 1 root root 29 Nov 24 2017 pyversions -> ../share/python/pyversions.py*
there's no immediate evidence that anything new was installed
ubuntu@ubuntu-xenial:/vagrant$ py3versions -i
python3.5
All I want is to have python3 >= 3.6 installed on this virtual machine. I don't at all care about previous installations, python2, virtualenvs, or any of the general server-health things, as this is a totally isolated development box.
Solution
For Ubuntu 16.04, you can use Felix Krull's deadsnakes PPA
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6
Alternatively, you can use J Fernyhough's PPA
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
If you want to Compile and install python 3.6 on Ubuntu 16.04
sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
tar xvf Python-3.6.0.tar.xz
cd Python-3.6.0/
./configure
sudo make altinstall
Answered By - user9730761 Answer Checked By - Senaida (WPSolving Volunteer)