0

I am trying to deploy a Flask app to Heroku and I keep getting this error. Anyone who can help me with this?

Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 4 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (9/9), 3.06 KiB | 184.00 KiB/s, done.
Total 9 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote:  !     No default language could be detected for this app.
remote:                         HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote:                         See https://devcenter.heroku.com/articles/buildpacks
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to expensetracker-api-heroku.
remote:
To https://git.heroku.com/expensetracker-api-heroku.git
 ! [remote rejected] secret-branchh -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/expensetracker-api-heroku.git'
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135

1 Answers1

0

Based on the UPDATED question, the error message is hinting at the problem:

No default language could be detected for this app.

You need to tell Heroku what kind of app you are deploying. For Python apps (i.e. Flask), you need to have one of the following files in your top-level git directory, as described in the Expected files for Python section of Deploying Python and Django Apps on Heroku docs:

Heroku automatically identifies your app as a Python app if any of the following files are present in its root directory:

  • requirements.txt
  • setup.py
  • Pipfile

If none of these files is present in your app’s root directory, the Python buildpack will fail to identify your application correctly.

Take note of the the warning at the end that if none of the files are present, the Python buildpack will faill.

The simplest here is to add a requirements.txt file. You can generate this by doing:

pip freeze > requirements.txt

and it looks like this:

Flask==1.0.2
Flask-Scss==0.5
gunicorn==19.7.1
isort==4.3.3
itsdangerous==0.24
Jinja2==2.10.1
...

Add that to the top-level of your git directory.

Then, for Flask, you need to add a couple more files:

  • runtime.txt

    This specifies the Python version of your app, as described in Specifying a Python Runtime

    python-3.7.3
    
  • Procfile

    This is described in this post Heroku Flask Tutorial Procfile Meaning and I suggest you take a look. The contents depends on how you instantiated your Flask app instance, and it looks like this:

    web: gunicorn app:app --log-file=-
    

If you're still having problems, I highly recommend going through the Heroku tutorial docs, especially Getting Started on Heroku with Python.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135