Skip to content

Instantly share code, notes, and snippets.

@john-science
Last active July 11, 2021 22:56
Show Gist options
  • Save john-science/d43102fd64d7bbd406e0f03fb7441bca to your computer and use it in GitHub Desktop.
Save john-science/d43102fd64d7bbd406e0f03fb7441bca to your computer and use it in GitHub Desktop.
Installing Python v3.8 dev on Ubuntu 20.04 via Docker
FROM ubuntu:20.04
RUN apt-get update && \
apt-get install --no-install-recommends -y python3-pip python3.8-dev && \
apt-get install vim && \
apt-get install git
@iFreilicht
Copy link

iFreilicht commented Dec 11, 2020

A recommendation:

RUN apt-get update && \
    apt-get install --no-install-recommends -y \
    python3.8 python3-pip python3.8-dev

This way you don't install as much of python3.6 (which is included with python3-pip).

@john-science
Copy link
Author

RUN apt-get update &&
apt-get install --no-install-recommends -y
python3.8 python3-pip python3.8-dev

Thanks for that!

@nanguoyu
Copy link

In this way, you install python3.8 and python 3.6. And the default python3 is python3.6 instead of python3.8.

@john-science
Copy link
Author

In this way, you install python3.8 and python 3.6. And the default python3 is python3.6 instead of python3.8.

Are you sure? Because I am explicitly calling out "python3.8" by name.

@nanguoyu
Copy link

nanguoyu commented Jun 3, 2021

In this way, you install python3.8 and python 3.6. And the default python3 is python3.6 instead of python3.8.

Are you sure? Because I am explicitly calling out "python3.8" by name.

Hi, Yes. I just have a try. When I call python3, I get python 3.6.9. This is because that python3-pip would introduce python3.6.

@iFreilicht
Copy link

I can confirm this, but I'm not sure there's a good way around this. There's no python3.8-pip package in the Ubuntu repos, and for good reason. python3.6 is the default version of python3 for Ubuntu 18.04.

I guess one could use

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3.8 get-pip.py instead?

In theory it would be possible to then use update-alternatives, but that's probably risky.

@john-science
Copy link
Author

@iFreilicht and @nanguoyu Okay, this is pretty annoying. How would you guys feel about moving this Dockerfile to Ubuntu 20.04? I just checked and it looks like Python 3.8 is the default install there.

It would solve the issue of Python versions, and I personally want the newer version of Ubuntu. But if you guys want 18.04, I can maybe use the above curl hack.

@nanguoyu
Copy link

nanguoyu commented Jun 6, 2021

Yes, you can move to Ubuntu 20.04. If Ubuntu 18.04 and Python 3.8 are essential to you, you can install Python from source and then use update-alternatives.

See this: https://gist.github.com/nanguoyu/0f67ce488da4b3ca179d3af0c8cdc699

Miniconda maybe also a choice.

RUN wget \
    https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
    && mkdir /root/.conda \
    && bash Miniconda3-latest-Linux-x86_64.sh -b \
    && rm -f Miniconda3-latest-Linux-x86_64.sh 
    
RUN pip3 install --upgrade pip &&\
	pip3 install setuptools>=41.0.0

@iFreilicht
Copy link

@theJollySin I'm not using this dockerfile anyway, so I'm fine with you upgrading it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment