Docker Alpine Linux python (missing)
Asked Answered
M

5

64

I have a pipeline which deploys my container from GitLab. Last deployment was 5 days ago and went without any problems. Today I deploy it and get the following error:

$ apk add --no-cache curl python py-pip
 fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
 fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
 ERROR: unsatisfiable constraints:
   python (missing):
     required by: world[python]

My job definition is:

my-deploy:
  type: my-deploy
  image: docker:stable
  script:
    - apk update
    - apk add --no-cache curl python py-pip <-- Here the erorr happens
    ...
Massarelli answered 3/6, 2020 at 9:33 Comment(0)
M
92

From this issue on the Docker's repo:

This was "broken" while updating our base from alpine:3.11 to alpine:3.12.

In order to fix it you need to specify the version of Python directly, e.g.:

apk add python2
// or
apk add python3
Massarelli answered 30/6, 2020 at 7:51 Comment(2)
I am using docker windows desktop application. I received this error on getting-started repo. Come on! getting-started has issue? I updated the DockerFile RUN apk add --no-cache python g++ make with RUN apk add --no-cache python3 g++ make. This fixed the issue. Thanks.Fanniefannin
I was able to install python2 on ruby:2.7.6-alpine3.14 but not ruby:2.7.6-alpine3.15Eozoic
S
73

Try this command:

apk add --update --no-cache curl py-pip

It will install python3 automatically with pip.

My understanding is that Python 2 has been decommissioned from the latest Alpine packages.

Serenaserenade answered 3/6, 2020 at 9:37 Comment(4)
Sunsetting Python 2Absorbent
i dont think we need curl hereInutility
curl was in the question, so I think he included it to match thatEmeliaemelin
Thanks, python2 was no longer working for me but with py-pip it worked fine.Haeckel
M
21

For future readers:

I got a similar error with node:14-alpine

ERROR: unable to select packages:  
  python2 (no such package):  
    required by: world[python2]

But I couldn't use the other answers listed in this question because I needed exactly python2 and running apk add python2 was giving me the error above.

After a while I realized that in the latest alpine version, there's only python3 (there's no python2).

So the solution was to use an older version of alpine that have python2 (alpine v3.15).

So the fix was changing node:14-alpine to node:14-alpine3.15

I know this isn't the exact same error, but while trying to find an answer for my error, I always ended up here, so I'm leaving this for future readers that might have the same problem.

Motivate answered 26/7, 2022 at 14:48 Comment(3)
I m getting the same error in the pipelne. I m using image: node:16.15-alpine . But based on the Alpine page that you posted above, if i use node:16.15-alpine:3.15 is it going to pass ?Sundried
I kept the same nodejs image, i mention above, and i upgraded to python3. This is the affected line: apk --update add make g++ npm autoconf zlib-dev automake file nasm python3 git py-pipqSundried
Only this worked for me. After 3 days of solving same sh*t. Thanks!Rufusrug
P
5

I've fix following this https://gitlab.alpinelinux.org/alpine/aports/-/issues/11605

Updating your code to install python3:

before_script:
- apk add --update --no-cache curl jq py3-configobj py3-pip py3-setuptools python3 python3-dev
Picul answered 4/6, 2020 at 10:25 Comment(0)
N
3

What solved it for me is this solution posted on GitHub.

RUN echo -e "http://nl.alpinelinux.org/alpine/v3.5/main\nhttp://nl.alpinelinux.org/alpine/v3.5/community" > /etc/apk/repositories
Nussbaum answered 26/10, 2021 at 5:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.