Search code examples
pythonherokubuildpack

Failed for buildpack


I am trying to run a python file on my heroku. I tried not setting a build pack as well as setting one and neither seems to work. The only files in my branch are a .py and the .git folder Here is an error example:

Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 590 bytes | 590.00 KiB/s, done.
Total 3 (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 google-results.
remote:

Solution

  • https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-python

    You need the following 2 files additionally in your git repo: runtime.txt and requirements.txt

    runtime.txt is responsible for which Python version your program is going to use.

    cat runtime.txt
    python-3.7.2
    

    supported runtime.txt version changes from time to time so check out https://devcenter.heroku.com/articles/python-runtimes

    requirements.txt is needed to specify which libraries from https://pypi.org/ your project is depending on. Be sure to specify a version to avoid breakage.
    You can get a list of your currently installed python libraries with the command: python -m pip freeze > requirements.txt