LoginSignup
7
10

More than 1 year has passed since last update.

alpineでpip3: not foundになったら

Last updated at Posted at 2020-07-03

pip3 not found エラーがでました

JenkinsでDocker Imageを作成する際に件のエラーが出た。
エラー詳細は下記のような感じ。

変更前のDockerfile

FROM alpine

RUN apk --update-cache add \
    python3 \
    python3-dev \
    gcc \
    g++ \
    curl \
    bash

RUN curl -sSL https://sdk.cloud.google.com | bash
ENV PATH $PATH:/root/google-cloud-sdk/bin

RUN apk update  \
    && apk upgrade  \
    && gcloud components install kubectl

COPY ./requirements.txt /tmp/requirements.txt
RUN pip3 install --upgrade pip
RUN pip3 install -r /tmp/requirements.txt
  • コンソールログ
    pip3: not foundエラー
[0m ---> 1532f5abc8b7
Removing intermediate container 43dd3deb5a2a
Step 6/18 : COPY ./requirements.txt /tmp/requirements.txt
 ---> f670b2c8d83b
Step 7/18 : RUN pip3 install --upgrade pip
 ---> Running in eb003063baef
[91m/bin/sh: pip3: not found
[0mThe command '/bin/sh -c pip3 install --upgrade pip' returned a non-zero code: 127
Build step 'Execute shell' marked build as failure
Finished: FAILURE

解決策

py3-pipを入れましょう

変更後のDockerfile

FROM alpine

RUN apk --update-cache add \
    python3 \
    python3-dev \
    py3-pip \
    gcc \
    g++ \
    curl \
    bash

RUN curl -sSL https://sdk.cloud.google.com | bash
ENV PATH $PATH:/root/google-cloud-sdk/bin

RUN apk update  \
    && apk upgrade  \
    && gcloud components install kubectl

COPY ./requirements.txt /tmp/requirements.txt
RUN pip3 install --upgrade pip
RUN pip3 install -r /tmp/requirements.txt
  • コンソールログ
    これで問題なく動く
[0m ---> eac6c5580f52
Removing intermediate container bb0aed0b3399
Step 6/18 : COPY ./requirements.txt /tmp/requirements.txt
 ---> 6950ee7fd4a5
Step 7/18 : RUN pip install --upgrade pip
 ---> Running in d21dcaf4353c
Requirement already up-to-date: pip in /usr/lib/python3.8/site-packages (20.1.1)
 ---> c5ac41af673c
Removing intermediate container d21dcaf4353c
Step 8/18 : RUN pip install -r /tmp/requirements.txt
 ---> Running in 327efdaa6d2a
Collecting google-cloud-bigquery
  Downloading google_cloud_bigquery-1.25.0-py2.py3-none-any.whl (169 kB)
Collecting pandas
7
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
10