2

I can't update Python on Ubuntu 16.04 LTS from my Python 3.5.2 to 3.8. I found an existing post here which shows how to update Python to 3.8. I tried those steps are follows:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.8

However, after the third step, I get this error:

enter image description here

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Timothy Clotworthy
  • 1,960
  • 2
  • 19
  • 42

2 Answers2

15

My ubuntu did not have the latest pre-built packages so I had to install from source according to the following guide: here.

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
tar -xf Python-3.8.0.tgz
cd Python-3.8.0
./configure --enable-optimizations
make -j 8
sudo make altinstall
vvvvv
  • 25,404
  • 19
  • 49
  • 81
Timothy Clotworthy
  • 1,960
  • 2
  • 19
  • 42
  • Works great, thanks for the summary. Note that this **does not** overwrite the default system python3 binary, so you have to be explicit, eg: `python3.8 --version`. Also I ran into `AttributeError: module 'platform' has no attribute 'linux_distribution'` when trying to create a new virtual environment with virtualenv, but [venv](https://docs.python.org/3.8/library/venv.html) worked as expected. – maltem-za Dec 14 '22 at 14:36
4

The deadsnakes repo is no longer available for Ubuntu 16.04. You have to build python yourself. Please check my answer for installing any python version using pyenv on Ubuntu 16.04.

itsafire
  • 5,607
  • 3
  • 37
  • 48
  • after this procedure Ubuntu becomes a brick with broken shell, I had to edit .bashrc manually after loading the rescue copy from flash card – George Hazan Aug 24 '22 at 09:32
  • Ok noted. Probably your .bashrc did not end with a new line. I fixed it in the example. Thanks for the info @GeorgeHazan – itsafire Sep 06 '22 at 09:38