2017-10-13 30 views
0

Étrange - J'ai essayé et essayé de lancer cette application Flask - quelque chose semble mal fonctionner.Déploiement de l'application Flask - ImportError: aucun module nommé 'app'

$ pwd dans l'application Flask donne:

/home/winduplordvexxos/winduplordvexxos.com/windupflaskvexxos

$ ls dans l'application Flask donne:

__init__.py __pycache__ vexxos.py windupflaskvexxos.wsgi 

__init__.py est vide.

vexxos.py:

from flask import Flask 

app = Flask(__name__) 

@app.route('/') 
def api(): 
return 'Wind Up Lord Vexxos API' 

if __name__ == "__main__": 
    app.run(host='0.0.0.0') 

windupflaskvexxos.wsgi:

activate_this = '/home/winduplordvexxos/winduplordvexxos.com/winduplordvexxos_env/bin/activate_this.py' 
with open(activate_this) as file_: 
    exec(file_.read(), dict(__file__=activate_this)) 

import os, sys 

cwd = os.getcwd() 
sys.path.insert(0, cwd) 

try: 
    from .vexxos import app as application 
except Exception: #ImportError 
    from vexxos import app as application 

Cependant, tout ce que je vois à l'extrémité avant est:

enter image description here

/etc/apache2/site-available/000-default.conf:

<VirtualHost *:80> 

     ServerAlias flask.winduplordvexxos.com 
     ServerAdmin [email protected] 

     WSGIDaemonProcess windupflaskvexxos.com user=winduplordvexxos group=winduplordvexxos threads=5 
     WSGIScriptAlias//home/winduplordvexxos/winduplordvexxos.com/windupflaskvexxos/windupflaskvexxos.wsgi 

     <Directory /home/winduplordvexxos/winduplordvexxos.com/windupflaskvexxos/> 
      WSGIProcessGroup windupflaskvexxos.com 
      WSGIApplicationGroup %{GLOBAL} 
      WSGIScriptReloading On 
      Require all granted 
     </Directory> 

</VirtualHost> 

Vérification des journaux d'erreur apache m'a donné:

[Fri Oct 13 23:05:14.650945 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] mod_wsgi (pid=15561): Target WSGI script '/home/winduplordve$ 
[Fri Oct 13 23:05:14.651088 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] mod_wsgi (pid=15561): Exception occurred processing WSGI scr$ 
[Fri Oct 13 23:05:14.657996 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] Traceback (most recent call last): 
[Fri Oct 13 23:05:14.658060 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] File "/home/winduplordvexxos/winduplordvexxos.com/windupfl$ 
[Fri Oct 13 23:05:14.658071 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859]  from .vexxos import app as application 
[Fri Oct 13 23:05:14.658098 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] SystemError: Parent module '' not loaded, cannot perform rel$ 
[Fri Oct 13 23:05:14.658131 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] 
[Fri Oct 13 23:05:14.658146 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] During handling of the above exception, another exception oc$ 
[Fri Oct 13 23:05:14.658156 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] 
[Fri Oct 13 23:05:14.658180 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] Traceback (most recent call last): 
[Fri Oct 13 23:05:14.658229 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] File "/home/winduplordvexxos/winduplordvexxos.com/windupfl$ 
[Fri Oct 13 23:05:14.658248 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859]  from vexxos import app as application 
[Fri Oct 13 23:05:14.658286 2017] [wsgi:error] [pid 15561:tid 140103054321408] [remote 109.149.163.9:59859] ImportError: No module named 'vexxos' 
[Fri Oct 13 23:05:14.690252 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] mod_wsgi (pid=15561): Target WSGI script '/home/winduplordve$ 
[Fri Oct 13 23:05:14.690318 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] mod_wsgi (pid=15561): Exception occurred processing WSGI scr$ 
[Fri Oct 13 23:05:14.690468 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] Traceback (most recent call last): 
[Fri Oct 13 23:05:14.690515 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] File "/home/winduplordvexxos/winduplordvexxos.com/windupfl$ 
[Fri Oct 13 23:05:14.690525 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858]  from .vexxos import app as application 
[Fri Oct 13 23:05:14.690549 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] SystemError: Parent module '' not loaded, cannot perform rel$ 
[Fri Oct 13 23:05:14.690566 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] 
[Fri Oct 13 23:05:14.690573 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] During handling of the above exception, another exception oc$ 
[Fri Oct 13 23:05:14.690577 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] 
[Fri Oct 13 23:05:14.690589 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] Traceback (most recent call last): 
[Fri Oct 13 23:05:14.690610 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] File "/home/winduplordvexxos/winduplordvexxos.com/windupfl$ 
[Fri Oct 13 23:05:14.690619 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858]  from vexxos import app as application 
[Fri Oct 13 23:05:14.690637 2017] [wsgi:error] [pid 15561:tid 140103087892224] [remote 109.149.163.9:59858] ImportError: No module named 'vexxos' 

J'ai essayé un certain nombre de choses, essayez sauf sur le module d'importation etc, mais rien ne semble fonctionner ... quelqu'un peut-il aider avec cela?

Répondre

1

Vous devrez probablement indiquer à mod_wsgi où votre code utilise l'option python-path à WSGIDaemonProcess. Votre importation dans le fichier de script WSGI semble également incorrecte.

Pour python-path vous voulez probablement:

python-path=/home/winduplordvexxos/winduplordvexxos.com 

L'importation doit alors:

from windupflaskvexxos import app as application 

ou si app non tirés par les __init__.py, utilisez:

from windupflaskvexxos.vexxos import app as application 

Lire aussi sur la façon préférée de mettre en place un environnement virtuel nt avec mod_wsgi. La façon dont vous utilisez n'est pas la méthode recommandée.

+0

Genius! Cela a fonctionné - à titre de référence: j'ai utilisé une combinaison de l'ajout du chemin python (je pensais travailler avec des environnements virtuels à partir du flacon pocco docs ici: http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi /) était suffisant) et l'application d'importation 'de windupflaskvexxos.vexos en tant qu'application'. Je pense que je le perdais parce que le site principal est utilisé comme une application Django. –