You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级pip并使用虚拟环境后仍遇openvino安装匹配错误

问题:Docker构建时无法安装openvino依赖

错误信息

#8 10.13 ERROR: Could not find a version that satisfies the requirement openvino>=2022.1.0 (from versions: none)
#8 10.13 ERROR: No matching distribution found for openvino>=2022.1.0
------
executor failed running [/bin/bash -l -c python3.9 -m venv openvino_env &&     source openvino_env/bin/activate &&     python3.9 -m pip install --upgrade pip &&     pip3.9 install -r requirements.txt -t ./python]: exit code: 1

已尝试的解决方法

  • 升级pip
  • 使用虚拟环境安装
    以上方法均无效,设备为Macbook M1。

相关代码文件

Dockerfile

FROM python:3.9.9-bullseye

RUN apt-get update && \
    apt-get install -y \
    libgl1 libglib2.0-0 zip virtualenv


# Install dependencies
COPY ./requirements.txt .
SHELL ["/bin/bash", "-l", "-c"]
RUN python3.9 -m venv openvino_env && \
    source openvino_env/bin/activate && \
    python3.9 -m pip install --upgrade pip && \
    pip3.9 install -r requirements.txt -t ./python

# Zip it up for deployment.
RUN zip -r layer.zip ./python/
ENTRYPOINT ["/bin/bash", "-l"]

requirements.txt

openvino>=2022.1.0; platform_system != "Darwin" or platform_machine != 'arm64'
openvino-arm; platform_system == "Darwin" and platform.machine == 'arm64'

build_docker.sh

# Generates a base layer for the Lambda functions.

# Remove the container first (if it exists).
docker rm layer-container

# Build the base layer.
docker build -t base-layer .

# Rename it to layer-container.
docker run --name layer-container base-layer

# Copy the generated zip artifact so our CDK can use it.
docker cp layer-container:layer.zip . && echo "Created layer.zip with updated base layer."

问题原因

Macbook M1是arm64架构,默认构建的Docker镜像是arm64架构的Linux容器。此时容器内platform_system为Linux,platform_machine为aarch64(对应arm64)。

requirements.txt的第一个条件platform_system != "Darwin" or platform_machine != 'arm64'中,因为platform_system != "Darwin"为真,条件成立,pip会尝试安装openvino>=2022.1.0。但该版本的openvino没有提供arm64 Linux的预编译PyPI包,导致找不到匹配版本。

解决方案

方案1:调整requirements.txt的条件逻辑

明确区分不同架构的环境依赖,Linux arm64环境单独指定适配包(需确认包兼容性):

# Linux x86_64 环境安装标准openvino
openvino>=2022.1.0; platform_system == "Linux" and platform_machine == "x86_64"
# Darwin arm64 环境安装openvino-arm
openvino-arm; platform_system == "Darwin" and platform_machine == "arm64"
# Linux arm64 环境安装适配版本(若openvino-arm支持则用,否则需源码编译)
openvino-arm; platform_system == "Linux" and platform_machine == "aarch64"

方案2:强制构建x86_64架构镜像

如果你的Lambda运行环境是x86_64,修改build_docker.sh的构建命令,指定架构:

docker build --platform linux/amd64 -t base-layer .

这样容器内是x86_64架构,pip能匹配到对应的openvino预编译包,即可正常安装。

内容的提问来源于stack exchange,提问作者Haoyang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 14:40:24