pyenv local 3.11.5 This writes 3.11.5 to .python-version and automatically switches your shell to that version when inside the project.
- name: Setup Python uses: actions/setup-python@v5 with: python-version-file: '.python-version' This ensures your CI runs the exact same version as developers. While Lambda doesn't read .python-version directly, you can use it to generate your deployment image: .python version
By combining .python-version with a .envrc file, you can fully automate environment setup: pyenv local 3
monorepo/ ├── service_a/ │ ├── .python-version # 3.10.4 │ └── pyproject.toml ├── service_b/ │ ├── .python-version # 3.11.5 │ └── pyproject.toml For pyenv , you can set a version in ~/.pyenv/version (global). Not recommended for teams. Strategy 3: Environment Variables Override the version with PYENV_VERSION : .python version