How to deploy a Python app to Heroku

Dave O'Dea
Aug 13, 2018 · 2 min read

This post is intended to help those learning Python. It will help you deploy your new app to the web so you can test and share it with others. Heroku’s own instructions leave out a couple of steps for beginners and so this article gives you everything to get up and running.

- Git, if you need help with this, check out my other article here.
- Sign up for a Heroku account.
- Python version > 3.6 installed on your machine.
- Pipenv installed: $ pip install pipenv.

Heroku CLI:
Install the Heroku CLI(command line interface) so that you can deploy/manage your apps/projects from the command line.
$ denotes commands to be entered in the terminal/shell

- MacOS: `$ brew install heroku/brew/heroku`
- Windows: [Download installer]( .
- Ubuntu: $ sudo snap install heroku — classic

If you have a ready-to-use Python app, good and well! If not, let’s use one that Heroku provide for testing purposes so we can learn the process:
$ git clone

Move into the directory of your app or:
$ cd python-getting-started

Install a web server called [Gunicorn]( within your app:
$ pip install gunicorn

Add your app requirements:
$ pip freeze > requirements.txt

Create a new file with the name: `Procfile` no file extension. Read more on [Procfile](
Add to the Procfile, for this particular app:
$ web: gunicorn gettingstarted.wsgi

Your app will have a different setup i.e:
$ web: gunicorn app:app

The above command tells Heroku to start the web server along with the module and application names.

Install the requirements for your app:

$ pip install -r requirements.txt

Now we can deploy our

$ heroku create

Push our code to Heroku:
$ git push heroku master

You may need to ensure that at least one instance of your app is up and live:

$ heroku ps:scale web=1

The URL where your app is lve will be displayed or else you can open it in your browser:
$ heroku open

If you’d like to debug some issues, you can view the logs for your app in the CLI:
$ heroku logs — tail

Your app is now live on Heroku for you to test and share with others!

If you have any questions or additions to make, please let me know in the comments below or get in touch on Twitter.

~ Dave.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store