heroku: no default language could be detected for this app

后端 未结 11 752
予麋鹿
予麋鹿 2020-12-03 22:40

First time using Heroku. Trying to push. I have run the command:

heroku create --buildpack heroku/python

and it displayed

$ hero         


        
相关标签:
11条回答
  • 2020-12-03 23:09

    I had the same problem even after including runtime.txt. What worked was the inclusion of the requirements.txt

    0 讨论(0)
  • 2020-12-03 23:10

    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:

    • python-2.7.13
    • python-3.6.1

    try to change your python version in runtime.txt

    0 讨论(0)
  • 2020-12-03 23:13

    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

    0 讨论(0)
  • 2020-12-03 23:18

    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)
    
    0 讨论(0)
  • 2020-12-03 23:21

    Quick Solution

    1. Goto heroku dashboard (https://dashboard.heroku.com/)
    2. go inside app/project
    3. click setting
    4. scroll down little bit and click add build pack
    5. select your desired buildpack (in my case i have selected heroku/nodejs).

    TLDR;

    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.

    0 讨论(0)
  • 2020-12-03 23:21

    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

    0 讨论(0)
提交回复
热议问题