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.tomlCommon 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
- Set python-version directly, or add requires-python to pyproject.toml.
- Or point python-version-file at a .python-version file.
- Re-run; setup and cache keying succeed.
.github/workflows/ci.yml
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pipHow 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
GitHub Actions setup-python "Version not found / not available"Fix actions/setup-python "Version X was not found" - the requested Python version is not in the runner tool c…
actions/setup-node "Could not resolve dist for node-version-file"Fix actions/setup-node failing to resolve a Node version from node-version-file due to a missing or malformed…
GitHub Actions setup-python "Version not found" from a version fileFix GitHub Actions setup-python failing to resolve a Python version from a python-version-file (.python-versi…