python - Docker:离线安装python包
问题描述
我想做什么?
使用下载的轮文件安装 requirements.txt 中提到的所有依赖项,即在Docker中离线安装包
我做了什么?
通过遵循这个线程,我设法将我所有的轮子下载到一个 Wheelhouse 文件夹中mkdir wheelhouse && pip download -r requirements.txt -d wheelhouse
,并创建了一个压缩的 tarball wheelhouse.tar.gz
,其中包含我所有下载.whl
的文件以及一个requirements.txt
当我尝试使用 本地(Docker 外部)安装轮子时pip install -r wheelhouse/requirements.txt --no-index --find-links wheelhouse
,它可以工作!
但是当我在 Docker 中运行相同的程序时,它不会出现以下错误:
Processing ./wheelhouse/beautifulsoup4-4.8.2-py3-none-any.whl
ERROR: Could not find a version that satisfies the requirement blis==0.4.1 (from -r ./wheelhouse/requirements.txt (line 2)) (from versions: none)
ERROR: No matching distribution found for blis==0.4.1 (from -r ./wheelhouse/requirements.txt (line 2))
虽然实际上,轮子blis 0.4.1
存在于我的驾驶室目录中。
谁能帮我确定为什么它不能在 Docker 上运行并在本地运行?
Dockerfile
FROM python:3
COPY . /app
WORKDIR /app
RUN tar -zxf ./wheelhouse.tar.gz
RUN pip install -r ./wheelhouse/requirements.txt --no-index --find-links ./wheelhouse
wheelhouse
目录截图:
解决方案
推荐阅读
- sockets - 发送强制发送 X 字节的 UDP 数据报
- solr - solr 8“msg”:“错误:未知字段‘语言’”
- json - Angular 显示单个 http 响应
- javascript - V8 console.log 不打印
- javascript - 如何动态填充下拉输入框
- python - 如何为 --user-data-dir 指定唯一值?
- python - 使用 Slack bot 发送具有非 ascii 字符的文件
- css - CSS 过渡和变换样式不适用于移动设备
- angular - 订阅的对象类型上不存在属性
- powershell - 如何在 Enter-PSSession 会话中编辑文本文件?