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

GitHub Actions执行Poetry install报错:Key 'files'不存在

Poetry在GitHub Actions中安装依赖报错:Key "files" does not exist.

本地使用Poetry安装Python依赖一切正常,但在GitHub Actions工作流的【Install dependencies】步骤中出现运行时错误,具体报错信息如下:

4s
Run poetry install
Creating virtualenv ailyssa-backend in /home/runner/work/ailyssa_backend/ailyssa_backend/.venv
Installing dependencies from lock file

[NonExistentKey]
'Key "files" does not exist.'
Error: Process completed with exit code 1.

相关配置

GitHub Workflow配置

name: Linting

on:
  pull_request:
    branches: [ master ]
    types: [opened, synchronize]

jobs:
  linting:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        python-version: [3.9]
        os: [ubuntu-latest]
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}

    - name: Set up Poetry
      uses: abatilo/actions-poetry@v2.0.0

    - name: Install dependencies
      run:  poetry install

    - name: Run code quality check
      run:  poetry run pre-commit run -a

pyproject.toml内容

[tool.poetry]
name = "ailyssa_backend"
version = "4.0.9"
description = "The RESTful API for Ailytics using the Django Rest Framework"
authors = ["Shan Tharanga <63629580+ShanWeera@users.noreply.github.com>"]

[tool.poetry.dependencies]
python = "^3.9"
Django = "4.1.3"
djangorestframework = "^3.13.1"
django-environ = "^0.8.1"
djangorestframework-simplejwt = "^5.0.0"
drf-spectacular = {version = "0.25.1", extras = ["sidecar"]}
django-cors-headers = "^3.10.0"
uvicorn = "^0.16.0"
django-filter = "^21.1"
psycopg2 = "^2.9.3"
django-auditlog = "2.2.1"
boto3 = "^1.22.4"
django-allow-cidr = "^0.4.0"
pyppeteer = "^1.0.2"
plotly = "^5.8.1"
pandas = "^1.4.2"
psutil = "^5.9.1"
requests = "^2.28.0"
opencv-python = "^4.6.0"
tzdata = "^2022.1"
pyotp = "^2.6.0"
channels = "3.0.5"
dictdiffer = "^0.9.0"
deepmerge = "^1.0.1"
django-oauth-toolkit = "^2.1.0"
drf-writable-nested = "^0.7.0"
Twisted = {version = "22.10.0", extras = ["tls,http2"]}
pathvalidate = "^2.5.2"
humanize = "^4.4.0"

[tool.poetry.dev-dependencies]
pre-commit = "^2.15.0"
mypy = "^0.971"

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

[tool.poetry.scripts]
manage = 'manage:main'

[tool.black]
line-length = 120
skip-string-normalization = true
target-version = ['py38']
include = '''
/(\.pyi?$|\.pyt?$)/
'''
exclude = '''
/(\.eggs|\.git|\.hg|\.mypy_cache|\.tox|\.venv|_build|buck-out|build|dist|tests/.*/setup.py)/
'''

问题原因与解决方法

这个报错核心原因是本地与GitHub Actions中使用的Poetry版本不兼容,锁文件格式存在版本差异导致解析失败。

解决步骤:

  1. 统一Poetry版本

    • 先在本地终端运行poetry --version查看当前使用的版本号
    • 修改GitHub Workflow中的Set up Poetry步骤,指定和本地一致的版本:
      - name: Set up Poetry
        uses: abatilo/actions-poetry@v2.0.0
        with:
          poetry-version: "你的本地Poetry版本号"  # 示例:1.3.2
      
  2. 更新锁文件(若统一版本后仍报错)
    删除本地的poetry.lock文件,重新运行poetry lock生成适配当前Poetry版本的锁文件,然后提交更新后的锁文件到GitHub仓库。

  3. 确认锁文件完整性
    检查poetry.lock是否完整提交到仓库,避免因文件缺失或损坏导致解析错误。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 11:45:25