'Python runtime.txt to specify the Python runtime version
Question
Is runtime.txt the official Python way to specify the python version to use? I suppose it is not what Python supports out of the box and I believe the version of Python runtime depends on the binary package management of each system (apt, brew, yum), unless explicitly download from https://www.python.org/downloads/.
However, if there is a known mechanism to switch Python version, please advise.
Background
There are several articles, mostly from Heiroku related, about runtime.txt to be specific with which version of Python to run.
-
You can specify the version of Python to be used by your app by setting python-versionnumber in the runtime.txt file in the root of your application.
Solution 1:[1]
Review
Local
To get a list of all installed Python versions available through the launcher, run:
py --list
Get sure that version that you want to use presents here.
Then you can crete a virtual environment with specific version like:
py -3.9 -m venv env/place/you/want/to/save/to
or, with virtualenv:
virtualenv --python=python3.9 env/place/you/want/to/save/to
If you want to specify path to your python:
virtualenv --python=/usr/bin/python3.9 env/place/you/want/to/save/to
Instead 3.9 insert version you need.
https://stackoverflow.com/a/67259741/13363187
Server
You can watch your python version with pip:
env/Scripts/activate
pip -V
and specify runtime version at runtime.txt:
python-3.9.10
that version will be used at server automatically (for example, Heroku server support it).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ?????????? ?????? |
