First time using Heroku. Trying to push. I have run the command:
heroku create --buildpack heroku/python
and it displayed
$ hero
I had the same problem even after including runtime.txt. What worked was the inclusion of the requirements.txt
Heroku’s Python support extends to the latest stable release from the Python 2.x and Python 3.x series. Today, this support extends to these specific runtimes:
try to change your python version in runtime.txt
In my case I was in a sub git folder. When I looked at the root .git folder - the project indeed didn't had a package.json
file - so heroku could not identify the webpack
I can't remember how I fixed this but looking at the Date Modified
in my files after I posted this question I created two files:
runtime.txt
(thanks rurp) which contains:
python-3.5.2
Procfile
which contains:
web: gunicorn projectname.wsgi --log-file -
This is a Django project and projectname.wsgi
leads to a wsgi.py
located at
projectname/wsgi.py
This contains:
import os
import signal
import sys
import traceback
import time
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projectname.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
Actually what heroku does is, it tries to identify what project you are deploying by looking at files in your project, such as if your project have package.json
file it understands it is a nodejs project, if your project have requirements.txt
file it understands it is a python project and so on, see this document to see to know what languages you can run on a heroku server
as you know to run a specific project such as a nodejs project in a computer node runtime must be installed in that computer otherwise you can not nodejs app in the computer, what heroku does it runs each of your app in a different container, it means in one container it is only one app is running and of course that container have installed nodejs, so if a container runs only one app it doesnt make sense to install all other runtimes in the container so container have only one runtime in my case it is nodejs. they have ofcourse other type of containers such as one type for python and that container have installed python runtime(of a specific version) so if my app gets installed in python container it will not work because my app in in nodejs. for this very reason somehow we need to identify the type of app in beginning to choose correct container type, mostly heroku automatically detect it but if it is failed to detect you have to tell explicitly either by going to their dashboard settings or through runtime file in your project, and as you may have noticed you have do this only once.
Create Pipfile file in root folder and add python version
and packages required for application. check sample file here
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
[packages]
django = "*"
gunicorn = "*"
django-heroku = "*"
[requires]
python_version = "3.6"
Also check Configuring Django Apps for Heroku