Score:0

How can I install Python 3.8 on Ubuntu 16.04? (ppa:deadsnakes doesn't support Ubuntu 16.04 anymore)

co flag

I used to use the following gist to install Python 3.8 on Ubuntu 16.04:

# install PPA
sudo add-apt-repository ppa:deadsnakes/ppa

# update and install
sudo apt update
sudo apt install python3.8 python3.8-dev python3.8-venv

However, ppa:deadsnakes doesn't support Ubuntu 16.04 anymore, and the above script doesn't work:

 > [6/6] RUN apt install -y python3.8:
#9 0.222
#9 0.222 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#9 0.222
#9 0.224 Reading package lists...
#9 0.960 Building dependency tree...
#9 1.098 Reading state information...
#9 1.148 E: Unable to locate package python3.8
#9 1.148 E: Couldn't find any package by glob 'python3.8'
#9 1.148 E: Couldn't find any package by regex 'python3.8'

How can I install Python 3.8 on Ubuntu 16.04?

guiverc avatar
cn flag
[Ubuntu 16.04 LTS has reached the end of it's *standard* support life](https://fridge.ubuntu.com/2021/03/13/extended-security-maintenance-for-ubuntu-16-04-xenial-xerus-begins-april-30-2021/) thus is now off-topic here unless your question is specific to helping you move to a supported release of Ubuntu. Ubuntu 16.04 ESM support is available, but not on-topic here, see https://askubuntu.com/help/on-topic See also https://ubuntu.com/blog/ubuntu-16-04-lts-transitions-to-extended-security-maintenance-esm
us flag
You can set up miniconda https://docs.conda.io/en/latest/miniconda.html
Franck Dernoncourt avatar
co flag
@ArchismanPanigrahi thx! looks like `pyenv` works too.
Franck Dernoncourt avatar
co flag
@guiverc thank you, feel free to migrate to https://retrocomputing.stackexchange.com/
us flag
I don't think 16.04 is ancient enough for retrocomputing
Franck Dernoncourt avatar
co flag
@ArchismanPanigrahi would any other SE fit?
us flag
Maybe https://unix.stackexchange.com/ However, they may prefer not to answer it because we already have Ask Ubuntu for Ubuntu. I would suggest you to upgrade to Ubuntu 20.04 LTS, which is supported until 2025.
Franck Dernoncourt avatar
co flag
@ArchismanPanigrahi thank you, I can't upgrade this system.
Score:0
co flag

One can use conda to create a virtual environment with Python 3.8:

conda create -n py38test1 python=3.8
conda activate py38test1

Otherwise, one can use pyenv. To install pyenv:

# Install pyenv following the instructions from https://github.com/pyenv/pyenv-installer
curl https://pyenv.run | bash

# Run nano ~/.bashrc
# Add the following at the end
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

# Save file and run:
exec $SHELL

Running pyenv install --list | grep " 3\.[678]" will display the available python versions:

[...]
3.8
3.8-dev
[...]

To install python 3.8 in pyenv:

# To avoid the common issue "ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?" (https://github.com/pyenv/pyenv/wiki/Common-build-problems#error-the-python-ssl-extension-was-not-compiled-missing-the-openssl-lib)
sudo apt-get install libssl-dev

# To avoid the common issue "WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?" (https://github.com/pyenv/pyenv/wiki/Common-build-problems#error-the-python-ssl-extension-was-not-compiled-missing-the-openssl-lib)
apt-get install -y libreadline-dev

# Install the python target version 
pyenv install 3.8.12

To create a new pyenv virtual environment with python 3.8:

# Create a virtual environment with python 3.8:
pyenv virtualenv 3.8.12 test

To activate the virtual environment test:

pyenv activate test
eval "$(pyenv init --path)" # to activate python 3.8.12

(The additional eval "$(pyenv init --path)" is because of this issue.)

To deactivate the virtual environment:

pyenv deactivate

FYI, useful commands:

  • To view the installed python versions in pyenv: pyenv versions
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.