Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define Python version inside project

Tags:

python

Many times I work on other developers' projects. I need to detect the Python version they used and sometimes it is hard to find.

I want to define which interpreter version I am using inside my project so that future developers will know which one to use.

Is there any standard (acceptable) way to do it, is it README.md?

like image 810
Oz Bar-Shalom Avatar asked May 26 '26 03:05

Oz Bar-Shalom


1 Answers

pyenv has the .python-version file which can be created with:

pyenv local 3.8.0

The file simply contains the string 3.8.0. Users can then enable that specific python version with:

pyenv local

In Python Poetry you can add to your pyproject.toml:

[tool.poetry.dependencies]
python = "~2.7 || ^3.2"  # Compatible python versions must be declared here