docker - 为什么dockered centos无法识别 pip ?

标签 docker pip

我想用centos创建一个带有python和几个软件包的容器。我尝试在原始centos容器中运行几个命令。一切正常我已经安装了所有想要的东西。然后,我使用通过Dockerfile执行的相同命令创建了RUN,然后我得到/bin/sh: pip: command not found可能是什么问题?我的意思是根本。为什么所有内容都可以在命令行中执行但不能用RUN执行?我已经尝试了两种变体:

RUN command
RUN command
RUN pip install ...


RUN command\
    && command\
    && pip install ...

我执行的命令:
from centos

run yum install -y centos-release-scl\
    && yum install -y rh-python36\
    && scl enable rh-python36 bash\
    && pip install django

UPD:指向点的完整路径有所帮助。怎么了?

最佳答案

您需要先使用安装pip

yum install python-pip

或者如果您需要python3(来自epel)
yum install python36-pip

如果不确定,请询问yum:
yum whatprovides /usr/bin/pip

python2-pip-18.1-1.fc29.noarch : A tool for installing and managing Python 2 packages
Repo        : @System
Matched from:
Filename    : /usr/bin/pip

python2-pip-18.1-1.fc29.noarch : A tool for installing and managing Python 2 packages
Repo        : updates
Matched from:
Filename    : /usr/bin/pip

python2-pip-18.0-4.fc29.noarch : A tool for installing and managing Python 2 packages
Repo        : fedora
Matched from:
Filename    : /usr/bin/pip

此输出来自Fedora29,但您应该在Centos / RHEL中获得类似的结果

更新

来自评论

But when I execute same commands from docker run -ti centos everything is fine. What's the problem?



也许您的PATH以某种方式损坏了?您可以尝试完整的点子吗?

关于docker - 为什么dockered centos无法识别 pip ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55058587/

相关文章:

python - 模块未找到错误 : No module named 'pip.commands'

macos - brew 或 pip - 安装 credstash - 错误 - 在 taps/OSErr 中找不到命名公式 六-1.4.1-py2.7.egg-info 操作不允许

python - “jupyter notebook”命令在 Linux 上不起作用

amazon-web-services - Docker 拉取错误 AWS ECR "unauthorized: authentication required"

通过 Docker 的 Postgresql - postgres 没有自动运行

docker - 如何使用BUILDBOT_CONFIG_URL配置buildbot docker容器

python - 无法在 virtualenv 中使用 pip 安装软件包

docker - 无法在boot2docker vm中重新启动sshd

由于 docker-credential-helper 导致 Docker 构建崩溃

python - pip如何确定python包版本