gpt4 book ai didi

heroku - Flask 和 Heroku - ModuleNotFoundError : No module named 'app'

转载 作者:行者123 更新时间:2023-12-03 00:43:43 28 4
gpt4 key购买 nike

我正在尝试将 Flask 应用程序部署到 Heroku。部署后,应用程序崩溃,并收到错误 ModuleNotFoundError:没有名为“app”的模块。

项目结构:

.
├── ./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

我正在 virtualenv 中做我 pip 安装了这些依赖项pip 安装 Flaskpip 安装请求pip 安装 pytzpip 安装 prawpip 安装 beautifulsoup4pip 安装 google-api-python-clientpip 安装 python-dateutilpip 安装 python-espncricinfo点安装 Pandas pip 安装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

这是我的主要init.py

 app = Flask(__name__)



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

Procfile 网站:gunicorn 应用程序:应用程序 运行时.txt python-3.6.4

需求.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

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

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

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

最佳答案

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

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

关于heroku - Flask 和 Heroku - ModuleNotFoundError : No module named 'app' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48881293/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com