【问题标题】:docker pip install not working with requirements filedocker pip install 无法使用要求文件
【发布时间】:2020-07-03 05:05:26
【问题描述】:

我正在使用 docker 创建一个 python 容器。奇怪的事情正在发生, 当我使用 pip 安装一些东西时,它可以工作,而且很好,当我尝试使用需求文件时,我得到一个错误,系统找不到 pip。

想法?

FROM tensorflow/tensorflow:latest

RUN ["apt-get", "update" ,"-y"]

RUN ["apt-get", "upgrade","-y"]

RUN ["apt-get", "install", "python-pip", "python3-pip","-y"]

RUN ["apt-get", "update" ,"-y"]

RUN ["apt-get", "upgrade","-y"]

ADD requirements.txt /requirements.txt

RUN ["pip", "install", "keras"]

有效

同时

FROM tensorflow/tensorflow:latest

RUN ["apt-get", "update" ,"-y"]

RUN ["apt-get", "upgrade","-y"]

RUN ["apt-get", "install", "python-pip", "python3-pip","-y"]

RUN ["apt-get", "update" ,"-y"]

RUN ["apt-get", "upgrade","-y"]

ADD requirements.txt /requirements.txt

RUN ["pip", "install", "-r", "/requirements.txt"]

得到这个错误

/bin/sh: 1: [pip,: 未找到

【问题讨论】:

  • 通常,错误消息中的[command, 表明您没有正确引用 JSON 数组,尽管您在问题中的内容看起来是正确的。

标签: python docker ubuntu pip dockerfile


【解决方案1】:

你可以使用:

RUN pip install -r requirements.txt

【讨论】:

    【解决方案2】:

    您能否尝试删除所有括号和双引号以查看是否有变化。没有理由失败。

    【讨论】:

      猜你喜欢
      • 2020-09-14
      • 2021-08-03
      • 1970-01-01
      • 2021-06-01
      • 1970-01-01
      • 2019-09-13
      • 1970-01-01
      • 2015-12-17
      • 2019-12-23
      相关资源
      最近更新 更多