I'm trying to update an existing Dockerfile to switch from python3.5
to python3.8
, previously it was creating a symlink for python3.5
and pip3
like this:
RUN ln -s /usr/bin/pip3 /usr/bin/pip
RUN ln -s /usr/bin/python3 /usr/bin/python
I've updated the Dockerfile to install python3.8
from deadsnakes:ppa
apt-get install python3-pip python3.8-dev python3.8-distutils python3.8-venv
if I remove python3-pip
, it complains about gcc
C compiler or Python headers are not installed on this system. Try to run: sudo apt-get install gcc python3-dev
with these installations in place I'm trying to update existing symlink creation something like this:
RUN ln -s /usr/bin/pip3 /usr/local/lib/python3.8/dist-packages/pip
RUN ln -s /usr/bin/pip /usr/local/lib/python3.8/dist-packages/pip
RUN ln -s /usr/bin/python3.8 /usr/bin/python3
it fails, saying
ln: failed to create symbolic link '/usr/bin/python3': File exists
which I assume fails because python3
points to python3.6
.
if I try: RUN ln -s /usr/bin/python3.8 /usr/bin/python
it doesn't complain about symlink and image gets build successfully, but fails while installing requirements later (we use Makefile targets to install dependencies inside the container using pip
and pip-sync
):
ERROR: Cannot uninstall 'python-apt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
which I assume because python-apt
gets installed as part of the default python3.6
installation and python3.8
pip can't uninstall it.
PS: my Dockerfile image is based on Ubunut 18.04 which comes with python3.6
as default.
How can I properly switch Dockerfile / image from python3.5
to python3.8
? so I can later use pip
directly and it points to python3.8
's pip