Docker:脱机安装python包

2024-06-25 23:42:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我想做什么

使用下载的控制盘文件安装requirements.txt中提到的所有依赖项,即在Docker中脱机安装软件包

我做了什么

按照这个thread我设法使用mkdir wheelhouse && pip download -r requirements.txt -d wheelhouse将我所有的轮子下载到驾驶室文件夹中,并创建了一个压缩的tarball wheelhouse.tar.gz,其中包含我所有下载的.whl文件以及一个requirements.txt

当我尝试使用pip install -r wheelhouse/requirements.txt --no-index --find-links wheelhouse在本地(Docker外部)安装控制盘时,它可以工作

但当我在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的屏幕截图

c


Tags: installpip文件dockernofromtxtindex