【发布时间】: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