Category Archives: Python

Heroku updates to python

If you see a message like this during one of your heroku builds/pushes, here’s what you should do:

remote: -----> Python app detected
remote:  !     Python has released a security update! Please consider upgrading to python-3.7.7

Take a look at what your runtime.txt file looks like. Mine looks like:

$ more runtime.txt

So, fire up your favorite editor and make it match.

Then commit that file, and push it back up to your repo and heroku.

$ git push heroku master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 300 bytes | 12.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: -----> Python app detected
remote: -----> Found python-3.7.6, removing
remote: -----> No change in requirements detected, installing from cache
remote: -----> Installing python-3.7.7
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 2018.5.18…
remote:        Installing dependencies from Pipfile.lock (a33c91)…

Python Debugger

It’s pretty simple to have your python script jump out to the debugger.  Place these 2 lines right before where you want to start monitoring (otherwise, you’ll need to do a lot of stepping thru code).

import pdb

Some useful ones to remember are:

  • b: set a breakpoint
  • c: continue debugging until you hit a breakpoint
  • s: step through the code
  • n: to go to next line of code
  • l: list source code for the current file (default: 11 lines including the line being executed)
  • u: navigate up a stack frame
  • d: navigate down a stack frame
  • p: to print the value of an expression in the current context