Check heroku’s python ‘Get Started‘ docs for latest requirements. As per this, python3.9 is required. So let’s first install that:

On my Ubuntu 20 system, to install python 3.9:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.9

Install heroku cli if you don’t have it yet:

sudo snap install heroku --classic

Login to heroku:

heroku login

Clone the provided sample package:

git clone
mv python-getting-started emr
cd emr

Create an app on Heroku, which prepares Heroku to receive your source code:

heroku create
heroku create
 ›   Warning: heroku update available from 7.52.0 to 7.53.1.
Creating app... done, ⬢ safe-topaz-31075 |

Now, we can deploy the code:

git push heroku main

To make sure one instance is always running:

heroku ps:scale web=1

Shortcut to open the website:

heroku open

To view logs:

heroku logs --tail

Create a virtualenv for deployment:

virtualenv -p python3.9 venv
virtualenv -p python3.9 venv
created virtual environment in 142ms
  creator CPython3Posix(dest=/home/joel/emr/venv, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/joel/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

Upgrade pip:

pip3 install --upgrade pip

Install all dependencies:

cat requirements.txt | xargs -n 1 pip3 install --retries 1

You can start the app locally with

./ runserver

To add your own app, remove the directory hello, and create own app with: startapp newappname

Can add one’s own custom domain for this site with:

heroku domains:add domainname.tld

Next on the domain’s DNS panel, add CNAME entry to point to the heroku name: