Docker 容器中的requirements.txt 文件中出现“包不兼容”错误

问题描述 投票:0回答:1

我收到错误:

Downloading pytz-2024.1-py2.py3-none-any.whl (505 kB)
ERROR: Ignored the following versions that require a different python version: 1.19.4 Requires-Python >=3.5, <3.9; 2.5.2 Requires-Python !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,<3.9dev,>=2.7
ERROR: Could not find a version that satisfies the requirement pywin32==306 (from versions: none)
ERROR: No matching distribution found for pywin32==306

我想在使用 Windows 10 的 Docker 容器中运行本地聊天机器人的代码(使用 Python 3.10.4、Langchain、Ollama、chormadb 和 Streamlit)。

我的 Docker 文件如下所示:

    # Use the official Python image from the Docker Hub
FROM python:3.10.10-slim

# Set the working directory in the container
WORKDIR /app

# Copy the .env file into the container
COPY .env .

# Copy the current directory contents into the container at /app
COPY . /app

# Copy the requirements.txt file into the container
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Expose the port Streamlit will run on
EXPOSE 8501

# Run the Streamlit app
CMD ["streamlit", "run", "rag_debug2.py"]

但是,每次运行文件来构建 Docker 容器时,我都会遇到一个错误,指出我的

pytz
包与当前的 Python 版本兼容。另一方面,当我在 docker 容器外部(以及我的 python 虚拟环境内部)通过
pytz
检查 Package
pip show pytz
时,它显示 Package
pytz
已经存在。

(.venv) C:\Users\koshtiu\Desktop\RAG>pip show pytz
Name: pytz
Version: 2024.1
Summary: World timezone definitions, modern and historical    
Home-page: http://pythonhosted.org/pytz
Author: Stuart Bishop
Author-email: [email protected]
License: MIT
Location: c:\users\koshtiu\desktop\rag\.venv\lib\site-packages
Requires:
Required-by: pandas

有人可以解释一下问题是什么以及如何解决吗?

python-3.x docker dockerfile
1个回答
0
投票

根据我所看到的(这不是您完整的

requirements
和完整的构建输出),您的要求有
pywin32==306
,无论是传递还是直接:

错误:找不到满足 pywin32==306 要求的版本(来自版本:无)

错误:找不到 pywin32==306 的匹配发行版

Pywin32 仅在 Windows 上可用,

FROM python:3.10.10-slim
意味着您正在构建基于 Linux 的 Docker 映像。

您需要取消该要求。

pytz
的东西可能是转移注意力的东西。

© www.soinside.com 2019 - 2024. All rights reserved.