【问题标题】:Install python packages from github with Docker使用 Docker 从 github 安装 python 包
【发布时间】:2021-04-13 08:59:45
【问题描述】:

我正在尝试安装一个不在 PyPi 上的包。即来自github。将 repo 作为 git+url 添加到需求文件中给出了

ERROR: Error [Errno 2] No such file or directory: 'git' while executing command git clone -q https://github.com/Rapptz/discord-ext-menus /tmp/pip-req-build-147rct22
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

安装包完成

RUN python3 -m pip install -r requirements.txt

docs中指定

我也尝试了this 的解决方案,但答案搞砸了我的其他包。

dockerfile 几乎直接来自文档

FROM python:3.8-slim-buster

WORKDIR /app

COPY requirements.txt requirements.txt

RUN python3 -m pip install -r requirements.txt

COPY . .

CMD [ "python3", "main.py"]

requirements.txt

asyncpg==0.21.0
git+https://github.com/Rapptz/discord-ext-menus
discord.py==1.7.0
pre-commit==2.10.1
pyclean==2.0.0
pylint==2.6.0
python-dotenv==0.15.0

【问题讨论】:

  • 告诉我们你Dockerfilerequirements.txt

标签: python docker pip


【解决方案1】:

正如错误告诉我们的,我们必须简单地安装 git,以便 pip 可以克隆 repo 并运行安装文件。 我们可以用

安装git
RUN apt-get update && apt-get install -y git

我们还必须从 python 图像构建,上面的答案适用于python:3.8-slim-buster

【讨论】:

    猜你喜欢
    • 2018-05-13
    • 2014-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-03
    • 2013-02-22
    • 1970-01-01
    相关资源
    最近更新 更多