On alpine images python is not recognized as an installed package by apk.
This may be a problem if we install via apk any package which requires on python, because it will be installed twice.
This could be a problem expecially when the container should run with an other version of python.
Example Dockefile:
FROM python:3.6-alpine
# ampy depends on python3
# see https://pkgs.alpinelinux.org/package/edge/testing/aarch64/ampy
RUN apk add ampy
When launching this container there would be 2 versions of python installed:
/usr/local/bin/python and /usr/local/lib/python3.6/usr/bin/python and /usr/lib/python3.7This brings to an unpredictable environment, where the user normally uses the desired python interpreter while some commands may use the other one (which has its own library and packages).
Python is installed from source so apk doesn't see it
https://github.com/docker-library/python/blob/c4414a2fdbb7fa1e752f27565e41c7032b673a03/3.6/alpine3.10/Dockerfile#L29-L30
What about pip install ampy
https://pypi.org/project/ampy/
This may be an option if someone can install that package directly, but if we need a binary package which has a dependency which relies on python package it wont work.
ampy was just the first package that I found on alpine as dependant on python3.
This issue came out while I was working on a reporting engine which uses WeasyPrint. To install it I also need both cairo-svg python library and package (from apk), these binaries has a dependency which depends on python3 and then it installs the python3 package!
I "discovered" this issue while also trying to do remote debugging with VScode. Because, due to this double install, its tool was using the package interpreter rather then the image one and "thanks" to this debugging is impossible since packages installed via pipare in an other environment.
As of now my main process (aka: converting HTML to PDF) does not have any issue, but I am worried that something may break and cause a big headache.
Last this "doubles" the size of derived images.
See https://github.com/docker-library/faq#why-do-so-many-official-images-build-from-source
Debian and Alpine package repos have only the latest version of Python 2.7 and 3.x, whereas Python will support version 3.5 until 9/13/20, so we install from source to obtain the latest release of each supported version https://devguide.python.org/#status-of-python-branches
https://wiki.debian.org/Python#Supported_Python_Versions
https://pkgs.alpinelinux.org/packages?name=python2&branch=v3.10
https://pkgs.alpinelinux.org/packages?name=python3&branch=v3.10
So in your case, you're specifying Python version 3.6, however the ampy package from the Alpine repo will use Python version 3.7.5-r1
That pip package is a different one actually, so what you probably want is to install ampy from source https://github.com/scientifichackers/ampy
As that would allow you to use Python 3.6 as you've specified
You can use ampy with either Python 2.7.x or 3.x