You can create this file manually or via your version manager's command line:
The layout of a .python-version file is beautifully simple. It contains exactly one line of text specifying the version string. However, depending on your version manager of choice, the depth of that string can vary. 1. The Explicit Patch Version (Recommended for pyenv)
: Follow the installation guide on the pyenv GitHub repository.
Cloud automation platforms like GitHub Actions and CircleCI can inspect your repository's .python-version file during initialization stages. This allows setup steps to pull the exact language binary without hardcoding string variables directly into the YAML workflow configurations. How to Create and Configure a .python-version File .python version
Instead of configuring environment variables manually or relying on complex global configurations, version managers scan this file to set the active runtime automatically whenever a developer enters the directory. 3.12.2 Use code with caution. How Version Managers Use .python-version
Then source ~/.zshrc to apply changes.
Pyenv is the most popular tool built around this system. It intercepts Python commands using "shims"—lightweight executables that pass commands to the correct version. When you type python in a terminal, Pyenv checks the current directory for a .python-version file. If found, it routes execution to that exact version. 2. Rye and UV You can create this file manually or via
that allows disabling the Global Interpreter Lock (GIL), potentially revolutionizing multi-core performance [33]. Python 3.11
Eliminates the friction of manually running activation commands when switching projects.
On Windows, tools expect \n (LF) line endings. If your editor saves with \r\n (CRLF), some older parsers may fail. Use dos2unix to convert. This allows setup steps to pull the exact
Python 2.7, the final release of the Python 2 branch, reached its official end of life on . Since then, the Python Software Foundation has ceased all maintenance, including security patches. Many Linux distributions—like openEuler—stopped supporting Python 2 entirely as early as 2022.
If Python is installed, the shell will report the version number.
in 3.13/3.14 have focused heavily on closing the performance gap with other languages [10, 38]. Modern Features : Recent versions have added powerful syntax like (3.6), the walrus operator (3.8), and structural pattern matching (3.10) [5, 37]. Python Version Support Roadmap
Most version managers will create this file for you when you set a local directory version. For example, using Pyenv: pyenv local 3.12.2 Use code with caution.