无法在 ubuntu 18.04 docker /bin/sh 中安装 pip: 1: pip: 未找到

cant install pip in ubuntu 18.04 docker /bin/sh: 1: pip: not found

我在 docker 图片中使用 pip 时遇到错误。

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y \
    software-properties-common
RUN add-apt-repository universe
RUN apt-get install -y \
    python3.6 \
    python3-pip

ENV PYTHONUNBUFFERED 1
RUN mkdir /api
WORKDIR /api

COPY . /api/
RUN pip install pipenv
RUN ls
RUN pipenv sync

我安装了 python 3.6 和 pip3 但得到

Step 9/11 : RUN pip install pipenv
 ---> Running in b184de4eb28e
/bin/sh: 1: pip: not found

为了 运行 pip 对于 python3 使用 pip3,而不是 pip

另一个解决方案。

您可以添加此行(在 apt-get 安装之后)。它会将 pip 升级到您需要的版本,例如:

RUN pip3 install --upgrade pip==20.0.1

然后您可以使用需求文件中的 pip install(例如):

RUN pip install -r requirements.txt