Skip to content
Latchkey

actions/setup-python cache fails: pyproject.toml has no version

setup-python can read the version from python-version-file. A pyproject.toml without a Python version (or with the version under a tool table the action does not read) leaves the version unresolved, breaking setup and cache keying.

What this error means

The setup-python step fails to resolve a version from pyproject.toml or the cache key cannot be computed.

github-actions
Error: Could not determine the Python version from the file: pyproject.toml
##[error]Version not found in pyproject.toml

Common causes

No Python version in pyproject

The file lacks a requires-python / tool version the action reads.

Wrong version-file target

python-version-file points at a file without a parseable version.

How to fix it

Provide python-version or a valid version file

  1. Set python-version directly, or add requires-python to pyproject.toml.
  2. Or point python-version-file at a .python-version file.
  3. Re-run; setup and cache keying succeed.
.github/workflows/ci.yml
- uses: actions/setup-python@v5
  with:
    python-version: '3.12'
    cache: pip

How to prevent it

  • Pin python-version explicitly when pyproject has no requires-python.
  • Keep the version file the action reads aligned with your tooling.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →