如何在 alpine linux 上安装 python?
How do I install python on alpine linux?
如何在基于 alpine 的图像上安装 python3 和 python3-pip(不使用 python 图像)?
$ apk add --update python3.8 python3-pip
ERROR: unsatisfiable constraints:
python3-pip (missing):
required by: world[python3-pip]
python3.8 (missing):
required by: world[python3.8]
这是我在 Dockerfile 中用于 alpine 图像的内容:
# Install python/pip
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
看这里:https://pkgs.alpinelinux.org/packages
所以你要找的是 python3
和 py3-pip
包。
在 dockerfile/etc 中使用的合适命令是:
apk add --no-cache python3 py3-pip
Explanation of the --no-cache
flag
但是请注意,您需要在 main
上 add the community repository since py3-pip
is not present。
你可以试试这个命令:
apk add python3
您可以使用 python 官方镜像,它也提供了 alpine 标签。您可能会获得最先进的 python 安装:
例如:
FROM python:3-alpine
而不是 python3-pip 安装 py3-pip
apk add --update python3 py3-pip
您似乎正在尝试安装 Python3 (3.8) 的特定次要版本,您可以在 Alpine 中使用像这样的 semver 来安装 python3>=3.8.0 <3.9.0-0
的版本:
apk add python3=~3.8
如何在基于 alpine 的图像上安装 python3 和 python3-pip(不使用 python 图像)?
$ apk add --update python3.8 python3-pip
ERROR: unsatisfiable constraints:
python3-pip (missing):
required by: world[python3-pip]
python3.8 (missing):
required by: world[python3.8]
这是我在 Dockerfile 中用于 alpine 图像的内容:
# Install python/pip
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
看这里:https://pkgs.alpinelinux.org/packages
所以你要找的是 python3
和 py3-pip
包。
在 dockerfile/etc 中使用的合适命令是:
apk add --no-cache python3 py3-pip
Explanation of the --no-cache
flag
但是请注意,您需要在 main
上 add the community repository since py3-pip
is not present。
你可以试试这个命令:
apk add python3
您可以使用 python 官方镜像,它也提供了 alpine 标签。您可能会获得最先进的 python 安装:
例如:
FROM python:3-alpine
而不是 python3-pip 安装 py3-pip
apk add --update python3 py3-pip
您似乎正在尝试安装 Python3 (3.8) 的特定次要版本,您可以在 Alpine 中使用像这样的 semver 来安装 python3>=3.8.0 <3.9.0-0
的版本:
apk add python3=~3.8