簡體   English   中英

屬性錯誤,與Heroku的gunicorn錯誤

[英]AttributeError, gunicorn error with Heroku

我目前正在使用Twilio API,Python Flask制作一個簡單的短信應用程序。 我正在使用heroku部署此應用程序。 當我使用Heroku部署應用程序時,它會導致錯誤:

AttributeError:'dict'對象沒有屬性'iteritems'

在reap_workers中輸入文件“/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py”,第459行

2015-10-25T09:53:57.727074 + 00:00 app [web.1]:提升HaltServer(原因,self.WORKER_BOOT_ERROR)2015-10-25T09:53:57.727123 + 00:00 app [web.1]:gunicorn .errors.HaltServer:

整個Heroku日志如下:

> 2015-10-25T09:53:57.695725+00:00 app[web.1]: [2015-10-25 09:53:57
> +0000] [7] [INFO] Worker exiting (pid: 7) 2015-10-25T09:53:57.725119+00:00 app[web.1]: Traceback (most recent
> call last): 2015-10-25T09:53:57.725131+00:00 app[web.1]:   File
> "/app/.heroku/python/bin/gunicorn", line 11, in <module>
> 2015-10-25T09:53:57.725453+00:00 app[web.1]:     sys.exit(run())
> 2015-10-25T09:53:57.725457+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py",
> line 74, in run 2015-10-25T09:53:57.725622+00:00 app[web.1]:    
> WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
> 2015-10-25T09:53:57.725626+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py",
> line 189, in run 2015-10-25T09:53:57.725832+00:00 app[web.1]:    
> super(Application, self).run() 2015-10-25T09:53:57.725836+00:00
> app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py",
> line 72, in run 2015-10-25T09:53:57.725968+00:00 app[web.1]:    
> Arbiter(self).run() 2015-10-25T09:53:57.725971+00:00 app[web.1]:  
> File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 174, in run 2015-10-25T09:53:57.726129+00:00 app[web.1]:    
> self.manage_workers() 2015-10-25T09:53:57.726133+00:00 app[web.1]:  
> File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 477, in manage_workers 2015-10-25T09:53:57.726385+00:00
> app[web.1]:     self.spawn_workers() 2015-10-25T09:53:57.726387+00:00
> app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 541, in spawn_workers 2015-10-25T09:53:57.726632+00:00
> app[web.1]:     time.sleep(0.1 * random.random())
> 2015-10-25T09:53:57.726636+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 214, in handle_chld 2015-10-25T09:53:57.726809+00:00 app[web.1]: 
> self.reap_workers() 2015-10-25T09:53:57.726813+00:00 app[web.1]:  
> File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 459, in reap_workers 2015-10-25T09:53:57.727074+00:00 app[web.1]:
> raise HaltServer(reason, self.WORKER_BOOT_ERROR)
> 2015-10-25T09:53:57.727123+00:00 app[web.1]:
> gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
> 2015-10-25T09:53:58.432435+00:00 heroku[web.1]: Process exited with
> status 1 2015-10-25T09:53:58.448971+00:00 heroku[web.1]: State changed
> from starting to crashed 2015-10-25T09:54:02.514159+00:00
> heroku[router]: at=error code=H10 desc="App crashed" method=GET
> path="/" host=(heroku app url)
> request_id=2ed6f5b7-551c-4039-a511-fc205d8a422c fwd="192.77.239.237"
> dyno= connect= service= status=503 bytes=
> 2015-10-25T09:55:29.244387+00:00 heroku[slug-compiler]: Slug
> compilation started 2015-10-25T09:55:29.244395+00:00
> heroku[slug-compiler]: Slug compilation finished
> 2015-10-25T09:55:29.176924+00:00 heroku[api]: Deploy 3602dc4 by
> (email address) 2015-10-25T09:55:29.176924+00:00 heroku[api]:
> Release v26 created by (email address)
> 2015-10-25T09:55:29.488257+00:00 heroku[web.1]: State changed from
> crashed to starting 2015-10-25T09:55:32.630390+00:00 heroku[web.1]:
> Starting process with command `gunicorn run:app`
> 2015-10-25T09:55:34.284215+00:00 heroku[web.1]: State changed from
> starting to up 2015-10-25T09:55:34.219364+00:00 app[web.1]:
> [2015-10-25 09:55:34 +0000] [3] [INFO] Listening at:
> http://0.0.0.0:7013 (3) 2015-10-25T09:55:34.219451+00:00 app[web.1]:
> [2015-10-25 09:55:34 +0000] [3] [INFO] Using worker: sync
> 2015-10-25T09:55:34.222305+00:00 app[web.1]: [2015-10-25 09:55:34
> +0000] [7] [INFO] Booting worker with pid: 7 2015-10-25T09:55:34.218674+00:00 app[web.1]: [2015-10-25 09:55:34
> +0000] [3] [INFO] Starting gunicorn 19.3.0 2015-10-25T09:55:34.233927+00:00 app[web.1]: [2015-10-25 09:55:34
> +0000] [7] [ERROR] Exception in worker process: 2015-10-25T09:55:34.233930+00:00 app[web.1]: Traceback (most recent
> call last): 2015-10-25T09:55:34.233932+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 507, in spawn_worker 2015-10-25T09:55:34.233932+00:00 app[web.1]:
> worker.init_process() 2015-10-25T09:55:34.233933+00:00 app[web.1]:  
> File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/workers/base.py",
> line 118, in init_process 2015-10-25T09:55:34.233934+00:00 app[web.1]:
> self.wsgi = self.app.wsgi() 2015-10-25T09:55:34.233935+00:00
> app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py",
> line 67, in wsgi 2015-10-25T09:55:34.233935+00:00 app[web.1]:    
> self.callable = self.load() 2015-10-25T09:55:34.233936+00:00
> app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py",
> line 65, in load 2015-10-25T09:55:34.233936+00:00 app[web.1]:    
> return self.load_wsgiapp() 2015-10-25T09:55:34.233937+00:00
> app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py",
> line 52, in load_wsgiapp 2015-10-25T09:55:34.233939+00:00 app[web.1]: 
> File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/util.py",
> line 355, in import_app 2015-10-25T09:55:34.233938+00:00 app[web.1]:  
> return util.import_app(self.app_uri) 2015-10-25T09:55:34.233940+00:00
> app[web.1]:   File "/app/run.py", line 1, in <module>
> 2015-10-25T09:55:34.233939+00:00 app[web.1]:     __import__(module)
> 2015-10-25T09:55:34.233940+00:00 app[web.1]:     from flask import
> Flask, request, redirect 2015-10-25T09:55:34.233941+00:00 app[web.1]: 
> File
> "/app/.heroku/python/lib/python3.5/site-packages/flask/__init__.py",
> line 17, in <module> 2015-10-25T09:55:34.233942+00:00 app[web.1]:    
> from werkzeug.exceptions import abort 2015-10-25T09:55:34.233942+00:00
> app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/werkzeug/__init__.py",
> line 109, in <module> 2015-10-25T09:55:34.233943+00:00 app[web.1]:    
> for module, items in all_by_module.iteritems():
> 2015-10-25T09:55:34.233944+00:00 app[web.1]: AttributeError: 'dict'
> object has no attribute 'iteritems' 2015-10-25T09:55:34.233945+00:00
> app[web.1]: Traceback (most recent call last):
> 2015-10-25T09:55:34.233946+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 507, in spawn_worker 2015-10-25T09:55:34.233946+00:00 app[web.1]:
> worker.init_process() 2015-10-25T09:55:34.233947+00:00 app[web.1]:  
> File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/workers/base.py",
> line 118, in init_process 2015-10-25T09:55:34.233948+00:00 app[web.1]:
> self.wsgi = self.app.wsgi() 2015-10-25T09:55:34.233949+00:00
> app[web.1]:     self.callable = self.load()
> 2015-10-25T09:55:34.233949+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py",
> line 67, in wsgi 2015-10-25T09:55:34.233950+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py",
> line 65, in load 2015-10-25T09:55:34.233951+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py",
> line 52, in load_wsgiapp 2015-10-25T09:55:34.233950+00:00 app[web.1]: 
> return self.load_wsgiapp() 2015-10-25T09:55:34.233952+00:00
> app[web.1]:     return util.import_app(self.app_uri)
> 2015-10-25T09:55:34.233953+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/util.py",
> line 355, in import_app 2015-10-25T09:55:34.233953+00:00 app[web.1]:  
> __import__(module) 2015-10-25T09:55:34.233954+00:00 app[web.1]:   File "/app/run.py", line 1, in <module> 2015-10-25T09:55:34.233955+00:00
> app[web.1]:     from flask import Flask, request, redirect
> 2015-10-25T09:55:34.233955+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/flask/__init__.py",
> line 17, in <module> 2015-10-25T09:55:34.233956+00:00 app[web.1]:    
> from werkzeug.exceptions import abort 2015-10-25T09:55:34.233957+00:00
> app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/werkzeug/__init__.py",
> line 109, in <module> 2015-10-25T09:55:34.233957+00:00 app[web.1]:    
> for module, items in all_by_module.iteritems():
> 2015-10-25T09:55:34.233961+00:00 app[web.1]: AttributeError: 'dict'
> object has no attribute 'iteritems' 2015-10-25T09:55:34.234066+00:00
> app[web.1]: [2015-10-25 09:55:34 +0000] [7] [INFO] Worker exiting
> (pid: 7) 2015-10-25T09:55:34.259788+00:00 app[web.1]: Traceback (most
> recent call last): 2015-10-25T09:55:34.259794+00:00 app[web.1]:   File
> "/app/.heroku/python/bin/gunicorn", line 11, in <module>
> 2015-10-25T09:55:34.260153+00:00 app[web.1]:     sys.exit(run())
> 2015-10-25T09:55:34.260158+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py",
> line 74, in run 2015-10-25T09:55:34.260366+00:00 app[web.1]:    
> WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
> 2015-10-25T09:55:34.260413+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py",
> line 189, in run 2015-10-25T09:55:34.261080+00:00 app[web.1]:    
> super(Application, self).run() 2015-10-25T09:55:34.261083+00:00
> app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py",
> line 72, in run 2015-10-25T09:55:34.262271+00:00 app[web.1]:    
> Arbiter(self).run() 2015-10-25T09:55:34.262276+00:00 app[web.1]:  
> File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 174, in run 2015-10-25T09:55:34.262277+00:00 app[web.1]:    
> self.manage_workers() 2015-10-25T09:55:34.262278+00:00 app[web.1]:  
> File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 477, in manage_workers 2015-10-25T09:55:34.262279+00:00
> app[web.1]:     self.spawn_workers() 2015-10-25T09:55:34.262280+00:00
> app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 541, in spawn_workers 2015-10-25T09:55:34.262280+00:00
> app[web.1]:     time.sleep(0.1 * random.random())
> 2015-10-25T09:55:34.262281+00:00 app[web.1]:   File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 214, in handle_chld 2015-10-25T09:55:34.262329+00:00 app[web.1]: 
> self.reap_workers() 2015-10-25T09:55:34.262333+00:00 app[web.1]:  
> File
> "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py",
> line 459, in reap_workers 2015-10-25T09:55:34.262607+00:00 app[web.1]:
> raise HaltServer(reason, self.WORKER_BOOT_ERROR)
> 2015-10-25T09:55:34.262626+00:00 app[web.1]:
> gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
> 2015-10-25T09:55:35.007220+00:00 heroku[web.1]: Process exited with
> status 1 2015-10-25T09:55:35.023047+00:00 heroku[web.1]: State changed
> from up to crashed 2015-10-25T09:55:39.958365+00:00 heroku[router]:
> at=error code=H10 desc="App crashed" method=GET path="/"
> host=(heroku app url)
> request_id=bd5ad9de-421d-418c-aa43-eaf4d26b21bf fwd="192.77.239.237"
> dyno= connect= service= status=503 bytes=
> 2015-10-25T09:58:12.278592+00:00 heroku[router]: at=error code=H10
> desc="App crashed" method=GET path="/"
> host=(heroku app url)
> request_id=c71bd1d4-f810-4c08-9017-82dff28aa19f fwd="192.77.239.237"
> dyno= connect= service= status=503 bytes=

這是requirements.txt:

> Flask==0.10.1 gunicorn==19.3.0 httplib2==0.9.2 itsdangerous==0.24
> Jinja2==2.6 MarkupSafe==0.23 PySocks==1.5.6 pytz==2015.6 six==1.10.0
> twilio==4.6.0 Werkzeug==0.8.3 wheel==0.24.0

這是runtime.txt:

python-3.5.0

最后,這是我的run.py文件,這是我正在嘗試部署的應用程序它是使用Twilio API的硬編碼應用程序:

from flask import Flask, request, redirect
import twilio.twiml

app = Flask(__name__)

# Try adding your own number to this list!
callers = {
    "(number)": "(name)",
}

subjects = ["math", "science", "english"]

@app.route("/", methods=['GET', 'POST'])
def answering_algorithm():
    body = request.values.get('Body', None).lower()
    from_number = request.values.get('From', None)

    if from_number in callers:
        if body in subjects:
            if body == "math":
                message = "You have selected Math."
                + " We have from Grade 1 to Grade 6."
                + " Which Grade do you want to view?"
                + " Type like following example: math grade 1"

    if from_number in callers:
        if body == "math grade 1":
            message = "Welcome to Math Grade 1."
            + "We have Addition, Addition Part 2, Addition Part 3, "
            + "Subtraction, Subtraction Part 2."
            + " Please input the lesson you want to view. Ex) Addition."

    resp = twilio.twiml.Response()
    resp.message(message)

    return str(resp)

if __name__ == "__main__":
    app.run(debug=True)

在部署myoku應用程序時,我不確定導致錯誤的原因。 任何幫助表示贊賞

您正在使用Python 3.5在Heroku上部署。 Python 3.x中的字典沒有iteritemsiterkeysitervalues方法。 您需要使用itemskeysvalues

問題的根源似乎是你的Werkzeug版本。 版本0.9中添加了初始Python 3支持。 您應該升級到更新的版本。 10.4目前是最新的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM