【问题标题】:wsgi:error - Module Not Found Error in Ubuntu - Flask App Hostingwsgi:error - Ubuntu 中未找到模块错误 - Flask 应用程序托管
【发布时间】:2021-05-30 00:10:06
【问题描述】:

我在 ubuntu 服务器上托管一个烧瓶应用程序我安装了所有软件包,当我使用 python3 __init__.py 运行它时,我的 python 文件 (init.py) 工作正常,但它给了我一个 @ 987654322@当我尝试使用公共IP地址访问时。

我正确安装了所有模块。但我不知道为什么它给我错误

未找到模块。

这里是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...

【问题讨论】:

  • 嗨,你解决了这个问题吗?我遇到了同样的问题,这让我发疯,因为我花了整整 2 天时间。

标签: python apache flask-sqlalchemy ubuntu-16.04 mod-wsgi


【解决方案1】:

pip freeze 是否在已安装的软件包中返回 flask_login? 您的日志显示找不到 flask_login 模块。

【讨论】:

  • 是的,flask_login 和所有其他模块都列在那里。
  • 这并没有提供问题的答案。请考虑回答那些不需要用户确认的问题,直到您的声誉达到 50 并且能够对帖子发表评论。
猜你喜欢
  • 1970-01-01
  • 2021-04-07
  • 1970-01-01
  • 2017-05-22
  • 2017-03-09
  • 2022-06-10
  • 2019-04-26
  • 1970-01-01
  • 2022-11-10
相关资源
最近更新 更多