Heroku部署成功但没有找到模块

时间:2018-06-15 10:31:28

标签: django python-3.x heroku deployment

我正在将django教程中的民意调查应用程序部署到heroku。

从Pycharm看到的我的项目有如下分布: enter image description here

我的要求文件显示为:

Django==2.0.5
scikit-learn==0.19.1
numpy==1.13.3
pandas==0.22.0
pymysql==0.8.1
gunicorn==19.0.0

运行时

python-3.6.5

Procfile as:

web: gunicorn inf-shf-373.wsgi:application --log-file -

当我部署应用程序并进入浏览器时,我收到一条应用程序错误消息:

An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. 

我使用heroku logs --tail --app inf-shf-373检索日志  言。

日志

2018-06-15T10:08:51.529196+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-06-15T10:08:51.529198+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 356, in import_app
2018-06-15T10:08:51.529201+00:00 app[web.1]: ModuleNotFoundError: No module named 'inf-shf-373'
2018-06-15T10:08:51.529199+00:00 app[web.1]: __import__(module)
2018-06-15T10:08:51.529202+00:00 app[web.1]: Traceback (most recent call last):
2018-06-15T10:08:51.529203+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 502, in spawn_worker
2018-06-15T10:08:51.529205+00:00 app[web.1]: worker.init_process()
2018-06-15T10:08:51.529206+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 114, in init_process
2018-06-15T10:08:51.529208+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-06-15T10:08:51.529209+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 66, in wsgi
2018-06-15T10:08:51.529211+00:00 app[web.1]: self.callable = self.load()
2018-06-15T10:08:51.529212+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-06-15T10:08:51.529216+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-06-15T10:08:51.529214+00:00 app[web.1]: return self.load_wsgiapp()
2018-06-15T10:08:51.529218+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-06-15T10:08:51.529219+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 356, in import_app
2018-06-15T10:08:51.529221+00:00 app[web.1]: __import__(module)
2018-06-15T10:08:51.529222+00:00 app[web.1]: ModuleNotFoundError: No module named 'inf-shf-373'
2018-06-15T10:08:51.529340+00:00 app[web.1]: 2018-06-15 10:08:51 [8] [INFO] Worker exiting (pid: 8)
2018-06-15T10:08:51.568925+00:00 app[web.1]: Traceback (most recent call last):
2018-06-15T10:08:51.568993+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2018-06-15T10:08:51.569405+00:00 app[web.1]: load_entry_point('gunicorn==19.0.0', 'console_scripts', 'gunicorn')()
2018-06-15T10:08:51.569437+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2018-06-15T10:08:51.569696+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2018-06-15T10:08:51.569725+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 166, in run
2018-06-15T10:08:51.570022+00:00 app[web.1]: super(Application, self).run()
2018-06-15T10:08:51.570050+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 71, in run
2018-06-15T10:08:51.570255+00:00 app[web.1]: Arbiter(self).run()
2018-06-15T10:08:51.570283+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 169, in run
2018-06-15T10:08:51.570559+00:00 app[web.1]: self.manage_workers()
2018-06-15T10:08:51.570587+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
2018-06-15T10:08:51.571398+00:00 app[web.1]: self.spawn_workers()
2018-06-15T10:08:51.571426+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 537, in spawn_workers
2018-06-15T10:08:51.572443+00:00 app[web.1]: time.sleep(0.1 * random.random())
2018-06-15T10:08:51.572572+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 209, in handle_chld
2018-06-15T10:08:51.573025+00:00 app[web.1]: self.reap_workers()
2018-06-15T10:08:51.573611+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
2018-06-15T10:08:51.574215+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2018-06-15T10:08:51.574320+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2018-06-15T10:08:51.656203+00:00 heroku[web.1]: Process exited with status 1
2018-06-15T10:08:51.766089+00:00 heroku[web.1]: State changed from starting to crashed
2018-06-15T10:08:51.768196+00:00 heroku[web.1]: State changed from crashed to starting
2018-06-15T10:08:59.756644+00:00 heroku[web.1]: Starting process with command `gunicorn inf-shf-373.wsgi:application --log-file -`
2018-06-15T10:09:01.853255+00:00 heroku[web.1]: Process exited with status 1
2018-06-15T10:09:01.754462+00:00 app[web.1]: 2018-06-15 10:09:01 [4] [INFO] Starting gunicorn 19.0.0
2018-06-15T10:09:01.754969+00:00 app[web.1]: 2018-06-15 10:09:01 [4] [INFO] Listening at: http://0.0.0.0:24374 (4)
2018-06-15T10:09:01.755073+00:00 app[web.1]: 2018-06-15 10:09:01 [4] [INFO] Using worker: sync
2018-06-15T10:09:01.758731+00:00 app[web.1]: 2018-06-15 10:09:01 [8] [INFO] Booting worker with pid: 8
2018-06-15T10:09:01.762508+00:00 app[web.1]: 2018-06-15 10:09:01 [8] [ERROR] Exception in worker process:
2018-06-15T10:09:01.762510+00:00 app[web.1]: Traceback (most recent call last):
2018-06-15T10:09:01.762511+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 502, in spawn_worker
2018-06-15T10:09:01.762513+00:00 app[web.1]: worker.init_process()
2018-06-15T10:09:01.762514+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 114, in init_process
2018-06-15T10:09:01.762515+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-06-15T10:09:01.762516+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 66, in wsgi
2018-06-15T10:09:01.762517+00:00 app[web.1]: self.callable = self.load()
2018-06-15T10:09:01.762519+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-06-15T10:09:01.762520+00:00 app[web.1]: return self.load_wsgiapp()
2018-06-15T10:09:01.762521+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-06-15T10:09:01.762522+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-06-15T10:09:01.762523+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 356, in import_app
2018-06-15T10:09:01.762524+00:00 app[web.1]: __import__(module)
2018-06-15T10:09:01.762525+00:00 app[web.1]: ModuleNotFoundError: No module named 'inf-shf-373'
2018-06-15T10:09:01.762526+00:00 app[web.1]: Traceback (most recent call last):
2018-06-15T10:09:01.762527+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 502, in spawn_worker
2018-06-15T10:09:01.762528+00:00 app[web.1]: worker.init_process()
2018-06-15T10:09:01.762529+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 114, in init_process
2018-06-15T10:09:01.762530+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-06-15T10:09:01.762532+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 66, in wsgi
2018-06-15T10:09:01.762533+00:00 app[web.1]: self.callable = self.load()
2018-06-15T10:09:01.762534+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-06-15T10:09:01.762535+00:00 app[web.1]: return self.load_wsgiapp()
2018-06-15T10:09:01.762536+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-06-15T10:09:01.762537+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-06-15T10:09:01.762538+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 356, in import_app
2018-06-15T10:09:01.762543+00:00 app[web.1]: ModuleNotFoundError: No module named 'inf-shf-373'
2018-06-15T10:09:01.762539+00:00 app[web.1]: __import__(module)
2018-06-15T10:09:01.762635+00:00 app[web.1]: 2018-06-15 10:09:01 [8] [INFO] Worker exiting (pid: 8)
2018-06-15T10:09:01.790830+00:00 app[web.1]: Traceback (most recent call last):
2018-06-15T10:09:01.790840+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2018-06-15T10:09:01.791070+00:00 app[web.1]: load_entry_point('gunicorn==19.0.0', 'console_scripts', 'gunicorn')()
2018-06-15T10:09:01.791073+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2018-06-15T10:09:01.791209+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2018-06-15T10:09:01.791216+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 166, in run
2018-06-15T10:09:01.791357+00:00 app[web.1]: super(Application, self).run()
2018-06-15T10:09:01.791360+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 71, in run
2018-06-15T10:09:01.791467+00:00 app[web.1]: Arbiter(self).run()
2018-06-15T10:09:01.791470+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 169, in run
2018-06-15T10:09:01.791600+00:00 app[web.1]: self.manage_workers()
2018-06-15T10:09:01.791603+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
2018-06-15T10:09:01.791814+00:00 app[web.1]: self.spawn_workers()
2018-06-15T10:09:01.791816+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 537, in spawn_workers
2018-06-15T10:09:01.792051+00:00 app[web.1]: time.sleep(0.1 * random.random())
2018-06-15T10:09:01.792055+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 209, in handle_chld
2018-06-15T10:09:01.792184+00:00 app[web.1]: self.reap_workers()
2018-06-15T10:09:01.792187+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
2018-06-15T10:09:01.792383+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2018-06-15T10:09:01.792417+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2018-06-15T10:09:01.897234+00:00 heroku[web.1]: State changed from starting to crashed
2018-06-15T10:09:15.812856+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=inf-shf-373.herokuapp.com request_id=32838b77-14c1-4235-8ac1-9823f14dab4b fwd="80.94.4.53" dyno= connect= service= status=503 bytes= protocol=https

我相信我的项目目录中的setting.py没有名为inf-shf-373的应用,但它是由heroku创建的随机名称。这意味着我的整个应用名称,然后Procfile的引用应为surveys(尽管有教程,我将民意调查名称更改为调查)。

有关问题的任何参考?

修改 回答DanielRoseman: wsgi.py文件位于:code / computationalMarketing / computationalMarketing / wsgi.py

额外信息: 是否有可能问题是wsgi.py文件不在repo的主路径中? django项目是第一个computeMarketing文件夹(这个项目全部聚集在代码文件夹中),同一级别存在的其他文件夹是sql mods和vagrant文​​件。

1 个答案:

答案 0 :(得分:0)

最后我已经能够解决这个问题。

我在chdir处找到了参数gunicorn,在django应用程序中稳定了wsgi.py文件的路径。

一个例子:

web: gunicorn --chdir code/computationalMarketing computationalMarketing.wsgi --log-file -