Flask - WSGI - No module named 'flask'
Flask - WSGI - No module named 'flask'
我一直在跟随Sentdex的Flask教程。他使用Venv来设置他的Flask,但没有设置他的Python与Venv一起工作。我尝试在全局安装Flask - 但仍然无法工作。尝试浏览服务器返回500内部服务器错误,我得到了通常的“没有名为flask的模块”的错误。
错误日志(errorFGL.log):
[Sun Feb 05 11:22:32.043925 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] mod_wsgi (pid=26340): 目标WSGI脚本'/var/www-fgl/FlaskApp/flaskapp.wsgi'不能作为Python模块加载。
[Sun Feb 05 11:22:32.044105 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] mod_wsgi (pid=26340): 在处理WSGI脚本'/var/www-fgl/FlaskApp/flaskapp.wsgi'时发生异常。
[Sun Feb 05 11:22:32.044243 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] 追踪(最近的调用最先):
[Sun Feb 05 11:22:32.045011 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] File "/var/www-fgl/FlaskApp/flaskapp.wsgi", line 8, in
[Sun Feb 05 11:22:32.045070 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] from FlaskApp import app as application
[Sun Feb 05 11:22:32.045549 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] File "/var/www-fgl/FlaskApp/FlaskApp/__init__.py", line 1, in
[Sun Feb 05 11:22:32.045594 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] from flask import Flask
[Sun Feb 05 11:22:32.045689 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] ImportError: 没有名为'flask'的模块
__init__.py:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def homepage():
return "Success"
if __name__ == "__main__":
app.run()
flaskapp.wsgi:
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www-fgl/FlaskApp/")
from FlaskApp import app as application
application.secret_key = '[已删除]'
fgl-database.conf:
ServerName [已删除]
WSGIScriptAlias / /var/www-fgl/FlaskApp/flaskapp.wsgi
Require all granted
Alias /static /var/www-fgl/FlaskApp/FlaskApp/static
Require all granted
ErrorLog ${APACHE_LOG_DIR}/errorFGL.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/accessFGL.log combined