【发布时间】:2020-12-23 06:49:15
【问题描述】:
我使用 Python、SQLite 和 FLASK 构建了一个简单的待办事项应用程序。这是在我的虚拟环境中下载的软件包列表。
click==7.1.2
Flask==1.1.2
Flask-SQLAlchemy==2.4.4
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
SQLAlchemy==1.3.19
Werkzeug==1.0.1
应用程序在本地服务器上按预期工作,当我将其部署到 Azure 应用程序服务时,网站 url 出现错误,以下是 azure“诊断和解决问题”工具上显示的错误消息块:
2020-09-04T01:01:56.214383481Z File "/home/site/wwwroot/app.py", line 2, in
2020-09-04T01:01:56.214399081Z from flask_sqlalchemy import SQLAlchemy
2020-09-04T01:01:56.214461881Z ModuleNotFoundError: No module named 'flask_sqlalchemy'
2020-09-04T01:01:56.214481081Z [2020-09-04 01:01:56 +0000] [45] [INFO] Worker exiting (pid: 45)
2020-09-04T01:01:56.352306124Z [2020-09-04 01:01:56 +0000] [42] [INFO] Shutting down: Master
2020-09-04T01:01:56.352713924Z [2020-09-04 01:01:56 +0000] [42] [INFO] Reason: Worker failed to boot.
2020-09-04T01:01:53.584987085Z Generating `gunicorn` command for 'app:app'
2020-09-04T01:01:53.957940395Z Writing output script to '/opt/startup/startup.sh'
2020-09-04T01:01:54.279983390Z Found virtual environment .tar.gz archive.
2020-09-04T01:01:54.280612491Z Removing existing virtual environment directory /antenv3.6...
2020-09-04T01:01:54.283122391Z Extracting to directory /antenv3.6...
2020-09-04T01:01:54.833191954Z Using packages from virtual environment antenv3.6 located at /antenv3.6.
2020-09-04T01:01:54.833722854Z Updated PYTHONPATH to ':/antenv3.6/lib/python3.6/site-packages'
2020-09-04T01:01:55.632256500Z [2020-09-04 01:01:55 +0000] [42] [INFO] Starting gunicorn 20.0.4
2020-09-04T01:01:55.633461900Z [2020-09-04 01:01:55 +0000] [42] [INFO] Listening at: http://0.0.0.0:8000 (42)
2020-09-04T01:01:55.634047501Z [2020-09-04 01:01:55 +0000] [42] [INFO] Using worker: sync
2020-09-04T01:01:55.644017104Z [2020-09-04 01:01:55 +0000] [45] [INFO] Booting worker with pid: 45
2020-09-04T01:01:56.177488970Z [2020-09-04 01:01:56 +0000] [45] [ERROR] Exception in worker process
我的虚拟环境中显然安装了 flask_sqlalchemy 模块,为什么会出现这个错误? 甚至可以部署 SQLite webapps 吗?还是需要一些在线数据库服务器?
谢谢。
【问题讨论】:
-
部署到 Azure 时,它会创建一个新的虚拟环境。它需要一个
requirements.txt文件来知道要安装什么。你有最新的requirements.txt吗? -
@PGHE 感谢您的回复,这很有帮助。我必须使用 pip3 freeze --user > requirements.txt 创建一个 requirements.txt 文件
标签: python-3.x azure sqlite flask