10

I need to install python 3.8.10 in a container running ubuntu 16.04.

16.04 has no support anymore, so I need a way to install it there manually.

1 Answer 1

14

This follows from here

Add the following to your dockerfile, and change the python version as needed.

When the docker is up, python3.8 will be available in /usr/local/bin/python3.8

# compile python from source - avoid unsupported library problems
RUN apt update -y && sudo apt upgrade -y && \
    apt-get install -y wget build-essential checkinstall  libreadline-gplv2-dev  libncursesw5-dev  libssl-dev  libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev && \
    cd /usr/src && \
    sudo wget https://www.python.org/ftp/python/3.8.10/Python-3.8.10.tgz && \
    sudo tar xzf Python-3.8.10.tgz && \
    cd Python-3.8.10 && \
    sudo ./configure --enable-optimizations && \
    sudo make altinstall

Please note the following (standard [and quicker] way of installing) does not work for old ubuntu versions, due to end of support

RUN apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository -y ppa:deadsnakes/ppa && \
    apt-get update && \
    apt install -y python3.8

See also this to install into /usr/bin

1
  • If you're doing this in a Dockerfile, you probably want make install, not make altinstall as altinstall does not change paths or install it to a bin folder referred in usual default paths. install vs altinstall - stackoverflow.com/a/70513790/802203
    – Ani
    Jan 27 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.