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

离线pip安装失败 找不到build-system.requires要求的poetry-core包

离线pip安装本地项目提示找不到已预装poetry-core的问题排查

问题场景

基于预装poetry-core的Docker镜像部署时,在断网环境下执行pip安装本地项目,触发poetry-core依赖找不到的报错。

前置校验信息

已安装poetry-core版本验证

执行/usr/local/bin/python3 -m pip show poetry-core返回结果如下:

root@test-86978fffbb-6rx79:/home# /usr/local/bin/python3 -m pip show poetry-core
Name: poetry-core
Version: 1.0.8
Summary: Poetry PEP 517 Build Backend
Author: Sébastien Eustace
Author-email: sebastien@eustace.io
License: MIT
Location: /usr/local/lib/python3.9/site-packages
Requires: 
Required-by:

项目构建配置

项目根目录pyproject.toml内构建相关配置如下:

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api" 

完整报错信息

离线执行/usr/local/bin/python3 -m pip install /app/安装项目时返回错误:

root@test-86978fffbb-6rx79:/app# /usr/local/bin/python3 -m pip install /app/
Processing /app
  Installing build dependencies ... error
  error: subprocess-exited-with-error
  
  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [2 lines of output]
      ERROR: Could not find a version that satisfies the requirement poetry-core>=1.0.0 (from versions: none)
      ERROR: No matching distribution found for poetry-core>=1.0.0
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

根因分析

pip对符合PEP 517规范的项目执行安装时,默认会创建独立的隔离构建环境,在这个隔离环境中单独安装pyproject.toml里build-system.requires声明的所有构建依赖,不会复用宿主系统全局已经安装的Python包。
在完全断网的离线环境下,隔离环境无法从公网PyPI拉取poetry-core包,即使全局环境已经预装了符合版本要求的poetry-core,也不会被隔离构建环境识别,因此触发找不到包的报错。

解决方案

根据实际场景二选一即可:

  • 方案一:禁用构建隔离,直接复用全局预装依赖
    安装时添加--no-build-isolation参数,关闭pip的隔离构建逻辑,直接使用当前系统环境中已经安装好的构建依赖完成打包安装,执行命令:
    /usr/local/bin/python3 -m pip install --no-build-isolation /app/
    
    注意:使用该方案前必须确认当前全局环境已经安装了build-system.requires中声明的所有依赖,且版本满足要求,当前环境的poetry-core 1.0.8符合>=1.0.0的版本要求,可直接使用该方案。
  • 方案二:保留构建隔离,配置本地离线依赖源
    如果需要保留构建隔离的环境一致性,可以提前将poetry-core及其关联依赖的wheel安装包上传到容器内的本地目录,安装时通过参数指定仅从本地目录查找依赖、禁止联网拉取,pip会在隔离构建环境中从本地源安装所需依赖,示例命令:
    /usr/local/bin/python3 -m pip install --no-index --find-links=/opt/local-wheels /app/
    
    其中/opt/local-wheels替换为实际存放离线wheel包的目录路径。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.30 09:27:13