【问题标题】:Trying to execute easy_install or pip on docker build says command not found尝试在 docker build 上执行 easy_install 或 pip 说找不到命令
【发布时间】:2017-04-23 01:19:35
【问题描述】:

我正在尝试构建一个基于 amazonlinux 的 docker 容器,它有点像 centos。

我需要的软件包之一是 supervisor,它在官方 repos 上不可用,所以我必须使用 easy_install 或 pip。

问题是,虽然我尝试安装python-setuptools和python-pip,但是当我尝试这样做时:

RUN easy_install supervisor

RUN pip install supervisor

它说该命令不存在

/bin/sh: easy_install: command not found
The command '/bin/sh -c easy_install supervisor' returned a non-zero code: 127

我尝试使用完整路径,但结果相同,我看到其他 dockerfiles 人在 centos 图像上这样做。

【问题讨论】:

    标签: docker dockerfile


    【解决方案1】:

    过了一会儿,我找到了原因。

    默认情况下,yum 正在安装 python26,而 easy_install 脚本与 python27 一起运行,所以我必须调用 easy_install-2.6 或安装 python27 包

    【讨论】:

      【解决方案2】:

      不熟悉AWS的具体镜像,但是对于一般的centos镜像,需要先用yum命令安装pip或者easy_install,需要epel仓库:

      RUN yum -y install epel-release \
       && yum -y install python-pip python-setuptools \
       && yum clean all
      

      Python 在其页面上详细记录了该过程:https://packaging.python.org/install_requirements_linux/

      超级用户也有一些关于此的文档:https://superuser.com/q/877759/587488

      【讨论】:

      • 找到原因 -.- 实际上,python-setuptools 和 python-pip 在 repo 上,但默认情况下我正在安装 python26,而 easy_install 脚本与 python27 一起运行,所以我必须调用 easy_install -2.6 或者安装python27包。
      • 很好的发现,请务必将其发布为您问题的答案,因为它可能会在未来对其他人有所帮助。
      猜你喜欢
      • 2023-02-04
      • 1970-01-01
      • 2018-01-31
      • 1970-01-01
      • 2016-10-10
      • 1970-01-01
      • 2018-08-11
      • 1970-01-01
      • 2019-05-03
      相关资源
      最近更新 更多