2017-05-18 2 views
0

Je gunicorn installé dans mon env virtuel:django + virtualenv + gunicorn - Aucun module nommé django.core.wsgi?

$ pip install gunicorn 
Collecting gunicorn 
    Using cached gunicorn-19.7.1-py2.py3-none-any.whl 
Installing collected packages: gunicorn 
Successfully installed gunicorn-19.7.1 

Mais quand je lance mon application essaie avec elle:

$ gunicorn helloapp.wsgi 
[2017-05-18 22:42:36 +0000] [1963] [INFO] Starting gunicorn 19.6.0 
[2017-05-18 22:42:36 +0000] [1963] [INFO] Listening at: http://127.0.0.1:8000 (1963) 
[2017-05-18 22:42:36 +0000] [1963] [INFO] Using worker: sync 
[2017-05-18 22:42:36 +0000] [1967] [INFO] Booting worker with pid: 1967 
[2017-05-18 22:42:36 +0000] [1967] [ERROR] Exception in worker process 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 557, in spawn_worker 
    worker.init_process() 
    File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process 
    self.load_wsgi() 
    File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 136, in load_wsgi 
    self.wsgi = self.app.wsgi() 
    File "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi 
    self.callable = self.load() 
    File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load 
    return self.load_wsgiapp() 
    File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 
    return util.import_app(self.app_uri) 
    File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 384, in import_app 
    __import__(module) 
    File "/var/www/html/django-project/helloapp/helloapp/wsgi.py", line 12, in <module> 
    from django.core.wsgi import get_wsgi_application 
ImportError: No module named django.core.wsgi 
[2017-05-18 22:42:36 +0000] [1967] [INFO] Worker exiting (pid: 1967) 
[2017-05-18 22:42:36 +0000] [1963] [INFO] Shutting down: Master 
[2017-05-18 22:42:36 +0000] [1963] [INFO] Reason: Worker failed to boot. 

Ce que je fait de mal?

Ceci est ma structure de l'application: enter image description here

Toutes les idées?

Ceci est mon requirments.txt:

appdirs==1.4.3 
Django==1.11.1 
gunicorn==19.7.1 
packaging==16.8 
pyparsing==2.2.0 
pytz==2017.2 
six==1.10.0 

EDIT:

(env) [email protected]:/var/www/html/django-project/helloapp$ which gunicorn 
/var/www/html/django-project/helloapp/env/bin/gunicorn 

(env) [email protected]:/var/www/html/django-project/helloapp$ which pip 
/var/www/html/django-project/helloapp/env/bin/pip 
+0

Quelle est la sortie de 'qui gunicorn',' qui pip' et 'pip freeze' ... il pourrait y avoir différents pythons ou des environnements que les commandes frappons –

+0

@NickT s'il vous plaît voir mon édition ci-dessus. – laukok

+0

pouvez-vous partager le chemin complet de votre fichier wsgi !? – DhiaTN

Répondre

1

vous devriez vraiment l'exécuter comme suit:

gunicorn helloapp.wsgi:application 
  • Utilisation de base de gunicorn :

gunicorn [OPTIONS] APP_MODULE

APP_MODULE est du motif $(MODULE_NAME):$(VARIABLE_NAME)

+0

essayé. mais toujours la même erreur ... – laukok

+0

Avez-vous activé votre virtualenv? car on dirait qu'il ne trouve pas les modules django. – DhiaTN

+0

oui. l'env est activé. – laukok

1

En /etc/systemd/system/gunicorn.service, assurez-vous que votre répertoire de travail pointe vers votre répertoire d'applications.

[Unit] 
Description=gunicorn daemon 
After=network.target 

[Service] 
User=sammy 
Group=www-data 
WorkingDirectory=/home/sammy/myproject 
ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/sammy/myproject/myproject.sock myproject.wsgi:application