upgrade_db.sh: fix locating of python binary

This fixes two bugs:
    
upgrade fails when deps were installed to virtualenv but not system
upgrade fails when python==python3 (notably on arch)

also make use of `type` over `which` consistent across scripts