python - wsgi:error - Ubuntu 中未找到模块错误 - Flask App Hosting
问题描述
我在 ubuntu 服务器上托管了一个烧瓶应用程序,我安装了所有软件包,并且我的 python 文件(init .py)在我运行它时工作正常,但是当我尝试使用公共 IP 地址访问它时python3 __init__.py
它给了我一个。Internal Server Error
我正确安装了所有模块。但我不知道为什么它给了我错误
未找到模块。
这里是error.log
[Sun Feb 28 03:36:38.569432 2021] [mpm_prefork:notice] [pid 4692] AH00163: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun Feb 28 03:36:38.579915 2021] [core:notice] [pid 4692] AH00094: Command line: '/usr/sbin/apache2'
[Sun Feb 28 03:36:40.695140 2021] [wsgi:error] [pid 4696] [client 157.34.94.187:50553] mod_wsgi (pid=4696): Target WSGI script '/var/www/dj/dj.wsgi' cannot be loaded as Python module.
[Sun Feb 28 03:36:40.695209 2021] [wsgi:error] [pid 4696] [client 157.34.94.187:50553] mod_wsgi (pid=4696): Exception occurred processing WSGI script '/var/www/dj/dj.wsgi'.
[Sun Feb 28 03:36:40.695473 2021] [wsgi:error] [pid 4696] [client 157.34.94.187:50553] Traceback (most recent call last):
[Sun Feb 28 03:36:40.695503 2021] [wsgi:error] [pid 4696] [client 157.34.94.187:50553] File "/var/www/dj/dj.wsgi", line 7, in <module>
[Sun Feb 28 03:36:40.695508 2021] [wsgi:error] [pid 4696] [client 157.34.94.187:50553] from dj import app as application
[Sun Feb 28 03:36:40.695515 2021] [wsgi:error] [pid 4696] [client 157.34.94.187:50553] File "/var/www/dj/dj/__init__.py", line 2, in <module>
[Sun Feb 28 03:36:40.695519 2021] [wsgi:error] [pid 4696] [client 157.34.94.187:50553] from flask_login import login_required
[Sun Feb 28 03:36:40.695537 2021] [wsgi:error] [pid 4696] [client 157.34.94.187:50553] ModuleNotFoundError: No module named 'flask_login'
这是我的wsgi
文件
#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/dj/")
from dj import app as application
application.secret_key = 'SECERET'
这是我的项目结构-
--var
---www
----dj(folder)
-----dj(folder) , dj.wsgi
------- __init__.py, static...
解决方案
pip freeze 在已安装的软件包中返回 flask_login 吗?您的日志说它找不到 flask_login 模块。
推荐阅读
- c++ - 正方体总是缺少图片中的文本行
- python - AttributeError:模块“tensorflow”没有属性“compat”
- python - 将 JSON 解析为不带前缀的 Pandas
- ruby-on-rails - 葡萄添加新端点
- mongodb - Spring Boot Mongo DB中无法解析的日期错误格式
- sas - 用于内核密度 SAS 的默认值
- node.js - UnhandledPromiseRejectionWarning: 错误: 禁止 SendGrid WebAPI 错误
- docker - 如何在 ecs2 fargate 中通过 docker-compose up 运行 docker
- java - 在 Android 中运行 SQLite 查询
- c++ - 如何移动 QListWidgetItem?