In the world of Python development, .python-version is a simple text file used by version managers like
to automatically switch between different Python environments based on your current directory. How It Works When you enter a folder containing a .python-version
file, your version manager reads the file and automatically sets the specified Python version for that terminal session. File Content : It typically contains just a version number, such as Automatic Switching : It eliminates the need to manually run commands like conda activate source venv/bin/activate every time you switch projects. Hierarchical Check
: Version managers look for this file in the current directory first, then search upwards through parent directories until one is found or the global default is used. Common Use Cases Project Isolation
: Ensures every developer on a team uses the exact same Python version, preventing "it works on my machine" bugs. CI/CD Pipelines
: Automated tools can read this file to provision the correct environment for testing and deployment. Tool Compatibility : Some tools, like pyenv-virtualenv
, use this file to manage not just the core Python version but also associated virtual environments. Creation & Management
You can create this file manually or via command line tools: : Create a file named .python-version (or your preferred version) inside. Command Line pyenv local 3.12.0 will automatically generate or update the .python-version file in your current folder. like pyenv to start using these files?
.pyenv/version)For pyenv, you can set a version in ~/.pyenv/version (global). Not recommended for teams.
pyenv Uses .python-versionpyenv is the most popular Python version manager on macOS and Linux. It intercepts python commands and redirects them to the correct installed version.
If the requested version isn't installed, pyenv will warn you:
pyenv: version `3.11.5' is not installed (set by /path/to/.python-version)
Simply run:
pyenv install 3.11.5
Vercel respects .python-version for Python serverless functions. Supported versions: 3.9, 3.10, 3.11.

In the world of Python development, .python-version is a simple text file used by version managers like
to automatically switch between different Python environments based on your current directory. How It Works When you enter a folder containing a .python-version
file, your version manager reads the file and automatically sets the specified Python version for that terminal session. File Content : It typically contains just a version number, such as Automatic Switching : It eliminates the need to manually run commands like conda activate source venv/bin/activate every time you switch projects. Hierarchical Check
: Version managers look for this file in the current directory first, then search upwards through parent directories until one is found or the global default is used. Common Use Cases Project Isolation
: Ensures every developer on a team uses the exact same Python version, preventing "it works on my machine" bugs. CI/CD Pipelines
: Automated tools can read this file to provision the correct environment for testing and deployment. Tool Compatibility : Some tools, like pyenv-virtualenv
, use this file to manage not just the core Python version but also associated virtual environments. Creation & Management
You can create this file manually or via command line tools: : Create a file named .python-version (or your preferred version) inside. Command Line pyenv local 3.12.0 will automatically generate or update the .python-version file in your current folder. like pyenv to start using these files?
.pyenv/version)For pyenv, you can set a version in ~/.pyenv/version (global). Not recommended for teams.
pyenv Uses .python-versionpyenv is the most popular Python version manager on macOS and Linux. It intercepts python commands and redirects them to the correct installed version.
If the requested version isn't installed, pyenv will warn you:
pyenv: version `3.11.5' is not installed (set by /path/to/.python-version)
Simply run:
pyenv install 3.11.5
Vercel respects .python-version for Python serverless functions. Supported versions: 3.9, 3.10, 3.11.