When deploying a new build on a python heroku application, sometimes you get a message telling you to upgrade your version of python.
For example, during a recent build, I saw the following message: “Python has released a security update! Please consider upgrading to python-3.7.3“.
In general, it’s a good idea to always upgrade to the most recent security patch for your python version. And, practicing what I preach, I went ahead and upgraded to python 3.7.3
So, like me, you probably want to change your version of python in heroku. How can you do this?
Here’s a quick rundown of how to specify or change the version of python used in your python heroku build.
How to Change Your Python Version in Heroku
First, create a file called runtime.txt in the root directory of your project.
Then, open up this file in a text editor and specify your python version as follows:
You can now save your file and push your code up to your remote repository. The next time you build your application, the new version of python that you specified in your runtime.txt will be used.
After running git push heroku master or whatever your equivalent deploy command is, you should see the following output:
remote: -----> Found python-3.7.1, removing
remote: -----> Installing python-3.7.3
And that is it! Just like that you can upgrade your version of python in a python heroku application.
For more python tips, tricks, and guides you can check here.