本文介绍了Flask 和 Heroku - ModuleNotFoundError:没有名为“app"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Flask 应用程序部署到 Heroku.部署后,应用程序崩溃,我收到错误 ModuleNotFoundError: No module named 'app'.

项目结构:

.├── ./espncricinfo│ ├── ./exceptions.py│ ├── ./__init__.py│ ├── ./match.py│ ├── ./player.py│ ├── ./summary.py│├── ./pycricbuzz│ ├──./cricbuzz.py│ ├──./__init__.py├── ./pycricket│ ├── ./cricket.py│ ├──./__init__.py├── ./静态│ ├── ./bblpics│ ├── ./fonts│ ├── ./images│ ├── ./收藏夹│ ├── ./stylesheets├── ./模板│ ├── ./index.html│ ├── ./base.html│ ├── ./app.html│ ├── ./Smmary.html│ ├── ./Scorecard.html│ ├── ./News.html├── ./__init__.py│├── ./Procfile│├── ./requirements.txt│├── ./runtime.txt│├── ./bbl.py│└── ./score.py

我在 virtualenv 中做我 pip 安装了这些依赖项pip 安装烧瓶pip 安装请求pip 安装 pytzpip 安装虾pip 安装 beautifulsoup4pip 安装 google-api-python-clientpip 安装 python-dateutilpip 安装 python-espncricinfopip 安装熊猫pip 安装 gunicorn

pip freeze >要求.txtecho web: gunicorn app:app >配置文件echo python-3.6.4 >runtime.txt混帐初始化登录heroku 创建墙板球得分git 添加.git commit -m "fdf"git push heroku masterheroku 打开

这是我的主要init.py

 app = Flask(__name__)如果 __name__=="__main__":应用程序运行(调试=真)

Procfile web: gunicorn app:appruntime.txt python-3.6.4

Requirements.txt-

beautifulsoup4==4.6.0bs4==0.0.1证书==2018.1.18chardet==3.0.4点击==6.7日期解析器==0.7.0烧瓶==0.12.2google-api-python-client==1.6.5枪炮==19.7.1httplib2==0.10.3idna==2.6它的危险==0.24Jinja2==2.10标记安全==1.0numpy==1.14.0oauth2client==4.1.2熊猫==0.22.0大虾==5.3.0prawcore==0.13.0pyasn1==0.4.2pyasn1-modules==0.2.1python-dateutil==2.6.1python-espncricinfo==0.3.1pytz==2018.3正则表达式==2018.2.8请求==2.18.4rsa==3.4.2六==1.11.0tzlocal==1.5.1更新检查器==0.16uritemplate==3.0.0urllib3==1.22Werkzeug==0.14.1

我收到如下错误:错误的完整详细信息:

2018-02-20T06:52:40.000000+00:00 app[api]:构建成功2018-02-20T06:54:00.350992+00:00 heroku[web.1]:使用命令`gunicorn app:app`启动进程2018-02-20T06:54:01.598198+00:00 heroku[web.1]:使用命令`gunicorn app:app`启动进程2018-02-20T06:54:03.409972+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] 启动 gunicorn 19.7.12018-02-20T06:54:03.413413+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] 收听:http://0.0.0.0:34331 (4)2018-02-20T06:54:03.413643+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] 使用工人:同步2018-02-20T06:54:03.420766+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] 使用 pid 启动 worker:82018-02-20T06:54:03.431463+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [ERROR] 工作进程异常2018-02-20T06:54:03.431467+00:00 app[web.1]:回溯(最近一次通话):2018-02-20T06:54:03.431469+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",第578行,在 spawn_worker 中2018-02-20T06:54:03.431471+00:00 应用程序[web.1]:worker.init_process()2018-02-20T06:54:03.431473+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",行126、在init_process中2018-02-20T06:54:03.431474+00:00 应用程序[web.1]:self.load_wsgi()2018-02-20T06:54:03.431476+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",行135,在load_wsgi2018-02-20T06:54:03.431478+00:00 app[web.1]: self.wsgi = self.app.wsgi()2018-02-20T06:54:03.431480+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py",行67,在wsgi2018-02-20T06:54:03.431482+00:00 app[web.1]: self.callable = self.load()2018-02-20T06:54:03.431483+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",行65, 负载2018-02-20T06:54:03.431485+00:00 app[web.1]: 返回 self.load_wsgiapp()2018-02-20T06:54:03.431487+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",行52、在load_wsgiapp中2018-02-20T06:54:03.431489+00:00 app[web.1]: 返回 util.import_app(self.app_uri)2018-02-20T06:54:03.431490+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py",第352行,在 import_app 中2018-02-20T06:54:03.431492+00:00 app[web.1]: __import__(module)2018-02-20T06:54:03.431534+00:00 app[web.1]: ModuleNotFoundError: 没有名为app"的模块2018-02-20T06:54:03.431765+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] 工人退出 (pid: 8)2018-02-20T06:54:03.473017+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [9] [INFO] 使用 pid 启动 worker:92018-02-20T06:54:03.484252+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [9] [ERROR] 工作进程异常2018-02-20T06:54:03.484255+00:00 app[web.1]:回溯(最近一次通话):2018-02-20T06:54:03.484257+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",第578行,在 spawn_worker 中2018-02-20T06:54:03.484258+00:00 应用程序[web.1]:worker.init_process()2018-02-20T06:54:03.484260+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",行126、在init_process中2018-02-20T06:54:03.484262+00:00 应用程序[web.1]:self.load_wsgi()2018-02-20T06:54:03.484263+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",行135,在load_wsgi2018-02-20T06:54:03.484265+00:00 app[web.1]: self.wsgi = self.app.wsgi()2018-02-20T06:54:03.484267+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py",行67,在wsgi2018-02-20T06:54:03.484268+00:00 app[web.1]: self.callable = self.load()2018-02-20T06:54:03.484270+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",行65, 负载2018-02-20T06:54:03.484271+00:00 app[web.1]: 返回 self.load_wsgiapp()2018-02-20T06:54:03.484273+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",行52、在load_wsgiapp中2018-02-20T06:54:03.484275+00:00 app[web.1]: 返回 util.import_app(self.app_uri)2018-02-20T06:54:03.484277+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py",第352行,在 import_app 中2018-02-20T06:54:03.484278+00:00 app[web.1]: __import__(module)2018-02-20T06:54:03.484338+00:00 app[web.1]: ModuleNotFoundError: 没有名为app"的模块2018-02-20T06:54:03.484677+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [9] [INFO] 工人退出 (pid: 9)2018-02-20T06:54:03.590746+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] 关闭:Master2018-02-20T06:54:03.590997+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] 原因:Worker 无法启动.2018-02-20T06:54:03.801591+00:00 heroku[web.1]:进程以状态 3 退出2018-02-20T06:54:04.041064+00:00 heroku[web.1]:状态从开始变为崩溃2018-02-20T06:54:04.029283+00:00 heroku[web.1]:进程以状态 3 退出2018-02-20T06:54:03.896607+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] 启动 gunicorn 19.7.12018-02-20T06:54:03.897225+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] 收听:http://0.0.0.0:13017 (4)2018-02-20T06:54:03.897355+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] 使用工人:同步2018-02-20T06:54:03.901981+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] 使用 pid 引导工人:82018-02-20T06:54:03.907379+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [ERROR] 工作进程异常2018-02-20T06:54:03.907383+00:00 app[web.1]:回溯(最近一次通话):2018-02-20T06:54:03.907385+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",第578行,在 spawn_worker 中2018-02-20T06:54:03.907387+00:00 应用程序[web.1]:worker.init_process()2018-02-20T06:54:03.907389+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",行126、在init_process中2018-02-20T06:54:03.907391+00:00 应用程序[web.1]:self.load_wsgi()2018-02-20T06:54:03.907393+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",行135,在load_wsgi2018-02-20T06:54:03.907394+00:00 app[web.1]: self.wsgi = self.app.wsgi()2018-02-20T06:54:03.907396+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py",行67,在wsgi2018-02-20T06:54:03.907398+00:00 app[web.1]: self.callable = self.load()2018-02-20T06:54:03.907400+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",行65, 负载2018-02-20T06:54:03.907402+00:00 app[web.1]: 返回 self.load_wsgiapp()2018-02-20T06:54:03.907404+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",行52、在load_wsgiapp中2018-02-20T06:54:03.907406+00:00 app[web.1]: 返回 util.import_app(self.app_uri)2018-02-20T06:54:03.907408+00:00 app[web.1]:文件/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py",第352行,在 import_app 中2018-02-20T06:54:03.907410+00:00 app[web.1]: __import__(module)2018-02-20T06:54:03.907417+00:00 app[web.1]: ModuleNotFoundError: 没有名为app"的模块2018-02-20T06:54:03.907561+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] 工人退出 (pid: 8)2018-02-20T06:54:03.950849+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] 关闭:Master2018-02-20T06:54:03.950970+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] 原因:Worker 无法启动.2018-02-20T06:54:48.667089+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=the-wall-cricket.herokuapp.com request_id=ac09678c-ef2d-4f3a-9d96-f0c60232eef3 fwd="157.49.23.47" dyno=connect=service=status=503 bytes=protocol=https2018-02-20T06:54:51.281797+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=the-wall-cricket.herokuapp.com request_id=c779ab65-1b04-443a-b17b-438cfe914a17 fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https2018-02-20T06:54:51.189245+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=the-wall-cricket.herokuapp.com request_id=6d88e51d-44c6-4389-aac5-c24595aad59c fwd="157.49.105.219" dyno=connect=service=status=503 bytes=protocol=https2018-02-20T06:54:51.849753+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=the-wall-cricket.herokuapp.com request_id=501e291a-0426-477b-ab30-b9e2c00865fb fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https2018-02-20T06:54:52.823503+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=the-wall-cricket.herokuapp.com request_id=7173cf2e-806d-4675-8e9e-442624e55f1c fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https

这有什么问题,我如何才能成功部署应用程序??

解决方案

web:gunicorn app:app 是标准的 Procfile.它期望您的 .py 文件应命名为 app.py.

如果您想更改 .py 名称,您也应该更改 Procfile.web:gunicorn my_app_name:app之后你可以命名你的文件 - my_app_name.py

I'm trying to deploy a Flask app to Heroku. After deploying, application crashes and I get an error ModuleNotFoundError: No module named 'app'.

Project structure:

.
├── ./espncricinfo
│      ├── ./exceptions.py
│      ├── ./__init__.py
│      ├── ./match.py
│      ├── ./player.py
│      ├── ./summary.py
│
├── ./pycricbuzz
│      ├──./cricbuzz.py
│      ├──./ __init__.py
├── ./pycricket
│      ├── ./cricket.py
│      ├──./ __init__.py
├── ./static
│      ├── ./bblpics
│      ├── ./fonts
│      ├── ./images
│      ├── ./favascripts
│      ├── ./stylesheets
├── ./templates
│      ├── ./index.html
│      ├── ./base.html
│      ├── ./app.html
│      ├── ./Smmary.html
│      ├── ./Scorecard.html
│      ├── ./News.html
├── ./__init__.py
│
├── ./Procfile
│
├── ./requirements.txt
│
├── ./runtime.txt
│
├── ./bbl.py
│
└── ./score.py

I'm doing in virtualenvI pip installed these dependicespip install Flaskpip install requestspip install pytzpip install prawpip install beautifulsoup4pip install google-api-python-clientpip install python-dateutilpip install python-espncricinfopip install pandaspip install gunicorn

pip freeze > requirements.txt
echo web: gunicorn app:app > Procfile
echo python-3.6.4 >runtime.txt

git init
heroku login
heroku create the-wall-cricket-scores
git add .
git commit -m "fdf"
git push heroku master
heroku open

This is my main init.py

 app = Flask(__name__)



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

Procfile web: gunicorn app:app runtime.txt python-3.6.4

Requirements.txt-

beautifulsoup4==4.6.0
bs4==0.0.1
certifi==2018.1.18
chardet==3.0.4
click==6.7
dateparser==0.7.0
Flask==0.12.2
google-api-python-client==1.6.5
gunicorn==19.7.1
httplib2==0.10.3
idna==2.6
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
numpy==1.14.0
oauth2client==4.1.2
pandas==0.22.0
praw==5.3.0
prawcore==0.13.0
pyasn1==0.4.2
pyasn1-modules==0.2.1
python-dateutil==2.6.1
python-espncricinfo==0.3.1
pytz==2018.3
regex==2018.2.8
requests==2.18.4
rsa==3.4.2
six==1.11.0
tzlocal==1.5.1
update-checker==0.16
uritemplate==3.0.0
urllib3==1.22
Werkzeug==0.14.1

I get an error as follow :Error full details:

2018-02-20T06:52:40.000000+00:00 app[api]: Build succeeded
2018-02-20T06:54:00.350992+00:00 heroku[web.1]: Starting process with command `gunicorn app:app`
2018-02-20T06:54:01.598198+00:00 heroku[web.1]: Starting process with command `gunicorn app:app`
2018-02-20T06:54:03.409972+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-02-20T06:54:03.413413+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Listening at: http://0.0.0.0:34331 (4)
2018-02-20T06:54:03.413643+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Using worker: sync
2018-02-20T06:54:03.420766+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] Booting worker with pid: 8
2018-02-20T06:54:03.431463+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [ERROR] Exception in worker process
2018-02-20T06:54:03.431467+00:00 app[web.1]: Traceback (most recent call last):
2018-02-20T06:54:03.431469+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-02-20T06:54:03.431471+00:00 app[web.1]:     worker.init_process()
2018-02-20T06:54:03.431473+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-02-20T06:54:03.431474+00:00 app[web.1]:     self.load_wsgi()
2018-02-20T06:54:03.431476+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-02-20T06:54:03.431478+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2018-02-20T06:54:03.431480+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-02-20T06:54:03.431482+00:00 app[web.1]:     self.callable = self.load()
2018-02-20T06:54:03.431483+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-02-20T06:54:03.431485+00:00 app[web.1]:     return self.load_wsgiapp()
2018-02-20T06:54:03.431487+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-02-20T06:54:03.431489+00:00 app[web.1]:     return util.import_app(self.app_uri)
2018-02-20T06:54:03.431490+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-02-20T06:54:03.431492+00:00 app[web.1]:     __import__(module)
2018-02-20T06:54:03.431534+00:00 app[web.1]: ModuleNotFoundError: No module named 'app'
2018-02-20T06:54:03.431765+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] Worker exiting (pid: 8)
2018-02-20T06:54:03.473017+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [9] [INFO] Booting worker with pid: 9
2018-02-20T06:54:03.484252+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [9] [ERROR] Exception in worker process
2018-02-20T06:54:03.484255+00:00 app[web.1]: Traceback (most recent call last):
2018-02-20T06:54:03.484257+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-02-20T06:54:03.484258+00:00 app[web.1]:     worker.init_process()
2018-02-20T06:54:03.484260+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-02-20T06:54:03.484262+00:00 app[web.1]:     self.load_wsgi()
2018-02-20T06:54:03.484263+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-02-20T06:54:03.484265+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2018-02-20T06:54:03.484267+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-02-20T06:54:03.484268+00:00 app[web.1]:     self.callable = self.load()
2018-02-20T06:54:03.484270+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-02-20T06:54:03.484271+00:00 app[web.1]:     return self.load_wsgiapp()
2018-02-20T06:54:03.484273+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-02-20T06:54:03.484275+00:00 app[web.1]:     return util.import_app(self.app_uri)
2018-02-20T06:54:03.484277+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-02-20T06:54:03.484278+00:00 app[web.1]:     __import__(module)
2018-02-20T06:54:03.484338+00:00 app[web.1]: ModuleNotFoundError: No module named 'app'
2018-02-20T06:54:03.484677+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [9] [INFO] Worker exiting (pid: 9)
2018-02-20T06:54:03.590746+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Shutting down: Master
2018-02-20T06:54:03.590997+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-02-20T06:54:03.801591+00:00 heroku[web.1]: Process exited with status 3
2018-02-20T06:54:04.041064+00:00 heroku[web.1]: State changed from starting to crashed
2018-02-20T06:54:04.029283+00:00 heroku[web.1]: Process exited with status 3
2018-02-20T06:54:03.896607+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-02-20T06:54:03.897225+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Listening at: http://0.0.0.0:13017 (4)
2018-02-20T06:54:03.897355+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Using worker: sync
2018-02-20T06:54:03.901981+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] Booting worker with pid: 8
2018-02-20T06:54:03.907379+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [ERROR] Exception in worker process
2018-02-20T06:54:03.907383+00:00 app[web.1]: Traceback (most recent call last):
2018-02-20T06:54:03.907385+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-02-20T06:54:03.907387+00:00 app[web.1]:     worker.init_process()
2018-02-20T06:54:03.907389+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-02-20T06:54:03.907391+00:00 app[web.1]:     self.load_wsgi()
2018-02-20T06:54:03.907393+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-02-20T06:54:03.907394+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2018-02-20T06:54:03.907396+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-02-20T06:54:03.907398+00:00 app[web.1]:     self.callable = self.load()
2018-02-20T06:54:03.907400+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-02-20T06:54:03.907402+00:00 app[web.1]:     return self.load_wsgiapp()
2018-02-20T06:54:03.907404+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-02-20T06:54:03.907406+00:00 app[web.1]:     return util.import_app(self.app_uri)
2018-02-20T06:54:03.907408+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-02-20T06:54:03.907410+00:00 app[web.1]:     __import__(module)
2018-02-20T06:54:03.907417+00:00 app[web.1]: ModuleNotFoundError: No module named 'app'
2018-02-20T06:54:03.907561+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] Worker exiting (pid: 8)
2018-02-20T06:54:03.950849+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Shutting down: Master
2018-02-20T06:54:03.950970+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-02-20T06:54:48.667089+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=the-wall-cricket.herokuapp.com request_id=ac09678c-ef2d-4f3a-9d96-f0c60232eef3 fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https
2018-02-20T06:54:51.281797+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=the-wall-cricket.herokuapp.com request_id=c779ab65-1b04-443a-b17b-438cfe914a17 fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https
2018-02-20T06:54:51.189245+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=the-wall-cricket.herokuapp.com request_id=6d88e51d-44c6-4389-aac5-c24595aad59c fwd="157.49.105.219" dyno= connect= service= status=503 bytes= protocol=https
2018-02-20T06:54:51.849753+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=the-wall-cricket.herokuapp.com request_id=501e291a-0426-477b-ab30-b9e2c00865fb fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https
2018-02-20T06:54:52.823503+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=the-wall-cricket.herokuapp.com request_id=7173cf2e-806d-4675-8e9e-442624e55f1c fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https

what's wrong with this, How can I successfully deploy an app??

解决方案

web:gunicorn app:app is standard Procfile. It expects that your .py file should be named app.py.

If you want to change .py name you should change Procfile as well.web:gunicorn my_app_name:appAfter that you can name your file - my_app_name.py

这篇关于Flask 和 Heroku - ModuleNotFoundError:没有名为“app"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:15