2017-02-05 2 views
3

Ich habe Sentxes Flask-Tutorial verfolgt. Er benutzt einen Venv, um seinen Flask aufzustellen, aber er hat seinen Python nicht mit einem Venv arbeiten lassen. Ich habe versucht, Flask global zu installieren - aber es funktioniert immer noch nicht. Wenn Sie versuchen, zum Server zu wechseln, wird ein interner 500-Serverfehler zurückgegeben.Flask - WSGI - Kein Modul namens 'flask'

Ich erhalte den üblichen Fehler no module named 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): Target WSGI script '/var/www-fgl/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module. 
[Sun Feb 05 11:22:32.044105 2017] [wsgi:error] [pid 26340:tid 118578538694400] [client 86.52.205.25:49814] mod_wsgi (pid=26340): Exception occurred processing WSGI script '/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] Traceback (most recent call last): 
[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 <module> 
[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 <module> 
[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: No module named '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 = '[REDACTED]' 

fgl-database.conf

<VirtualHost *:80> 
     ServerName [REDACTED] 
     WSGIScriptAlias//var/www-fgl/FlaskApp/flaskapp.wsgi 
     <Directory /var/www-fgl> 
      Require all granted 
     </Directory> 
     Alias /static /var/www-fgl/FlaskApp/FlaskApp/static 
     <Directory /var/www-fgl/FlaskApp/FlaskApp/static/> 
      Require all granted 
     </Directory> 
     ErrorLog ${APACHE_LOG_DIR}/errorFGL.log 
     LogLevel warn 
     CustomLog ${APACHE_LOG_DIR}/accessFGL.log combined 




</VirtualHost> 
+0

Wenn Sie Flask global installiert haben, wird mod_wsgi wahrscheinlich für eine andere Python-Version kompiliert. Für eine virtuelle Python-Umgebung müssen Sie mod_wsgi mitteilen, wo es sich befindet. Siehe: http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html –

Antwort

Verwandte Themen