How do I install python on alpine linux?

家住魔仙堡 提交于 2021-02-18 20:08:05

问题


How do I install python3 and python3-pip on an alpine based image (without using a python image)?

 $ 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]

回答1:


This is what I use in a Dockerfile for an alpine image:

# 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



回答2:


Look here: https://pkgs.alpinelinux.org/packages So what you are looking for are the python3 and py3-pip packages.

A suitable command to use inside a dockerfile/etc would be:

apk add --no-cache python3 py3-pip

Explanation of the --no-cache flag

Note however, that you need to add the community repository since py3-pip is not present on main.




回答3:


You can try this command

apk add python3



来源:https://stackoverflow.com/questions/62554991/how-do-i-install-python-on-alpine-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!