Python 包无法安装在 docker 容器中
Python package not installable in docker container
我有这样的基本 python docker 容器文件:
FROM python:3.8
RUN pip install --upgrade pip
EXPOSE 8000
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Install pip requirements
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
WORKDIR /app
COPY . /app
RUN useradd appuser && chown -R appuser /app
USER appuser
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app:app"]
我想 运行 我的 Flask 应用程序在 docker 容器中使用这个定义文件。我可以在本地启动一个新的虚拟环境,通过 pip install -r requirements.txt
在 python 3.8 上安装所有内容,它不会失败。
构建 docker 映像时,无法安装 requirements.txt 中的所有软件包。例如 this 包失败:
ERROR: Could not find a version that satisfies the requirement cvxopt==1.2.5.post1
ERROR: No matching distribution found for cvxopt==1.2.5.post1
当我注释掉 requirements.txt 中的包时,一切似乎都有效。该软件包本身声称与 python >2.7 兼容。包 pywin32==228 here.
的行为相同
您应该将版本替换为 1.2.5 (pip install cvxopt==1.2.5
)
最新版本cvxopt 1.2.5.post1
不兼容所有架构:https://pypi.org/project/cvxopt/1.2.5.post1/#files
前一个与更多硬件兼容,应该能够 运行 在您的 Docker 图像上:https://pypi.org/project/cvxopt/1.2.5/#files
查看 wheel files in the package,cvxopt.1.2.5.post1 仅包含 Windows 的构建。对于 Linux(例如 docker 容器),您应该使用 cvxopt.1.2.5.
我有这样的基本 python docker 容器文件:
FROM python:3.8
RUN pip install --upgrade pip
EXPOSE 8000
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Install pip requirements
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
WORKDIR /app
COPY . /app
RUN useradd appuser && chown -R appuser /app
USER appuser
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app:app"]
我想 运行 我的 Flask 应用程序在 docker 容器中使用这个定义文件。我可以在本地启动一个新的虚拟环境,通过 pip install -r requirements.txt
在 python 3.8 上安装所有内容,它不会失败。
构建 docker 映像时,无法安装 requirements.txt 中的所有软件包。例如 this 包失败:
ERROR: Could not find a version that satisfies the requirement cvxopt==1.2.5.post1
ERROR: No matching distribution found for cvxopt==1.2.5.post1
当我注释掉 requirements.txt 中的包时,一切似乎都有效。该软件包本身声称与 python >2.7 兼容。包 pywin32==228 here.
的行为相同您应该将版本替换为 1.2.5 (pip install cvxopt==1.2.5
)
最新版本cvxopt 1.2.5.post1
不兼容所有架构:https://pypi.org/project/cvxopt/1.2.5.post1/#files
前一个与更多硬件兼容,应该能够 运行 在您的 Docker 图像上:https://pypi.org/project/cvxopt/1.2.5/#files
查看 wheel files in the package,cvxopt.1.2.5.post1 仅包含 Windows 的构建。对于 Linux(例如 docker 容器),您应该使用 cvxopt.1.2.5.