2. The Major/Minor Floating Version (Recommended for Cloud Hosting)
system
# Load pyenv virtualenv or standard venv layout python $(cat .python-version)
Tools like Heroku or Render read this file during deployment to install the correct runtime automatically .
:
import sys if sys.version_info < (3, 10): sys.exit("This script requires Python 3.10 or higher.")
Note: Heroku requires the python- prefix on the version string.
# Use a build argument or parse the file directly FROM python:3.12-slim WORKDIR /app COPY .python-version . # Your remaining build steps Use code with caution. GitHub Actions Integration
: 3.13 (Often used by platforms like Render to automatically pull the latest patch). 2. Creation Methods .python version
Now python , pip , and any scripts run inside this directory will use Python 3.11.5 consistently.
You can create this file manually or via your version manager's command line:
pyenv install 3.13.13
This gap between dependency isolation (venv) and interpreter management (pyenv) is the root of most version‑related confusion. # Use a build argument or parse the
Tools like pipenv and poetry read the current Python version to create deterministic lock files. If your environment changes, you may generate incompatible lock files.
:
Before we dive into tools, let's decode what those numbers actually mean.