2017-03-21 7 views
0

この質問はsaverel時代に尋ねました。私はすべてのことを試みたが、私はこのエラーを解決することができません。私はnginxで私のdjangoアプリを展開していますが、このエラーが発生しています。 私のWSGIファイルImportError:nginxでデプロイするとdjango.core.wsgiという名前のモジュールがありません

import os, sys 
# add the hellodjango project path into the sys.path 
sys.path.append('/home/ubuntu/webapps/microbird/lib/python2.7/site-packages') 


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "microbird.settings") 
from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

は、私はこのエラーを取得しています

[uWSGI] getting INI configuration from run_microbird.ini 
open("./python_plugin.so"): No such file or directory [core/utils.c line 3684] 
!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!! 
*** Starting uWSGI 2.0.14 (64bit) on [Tue Mar 21 19:46:25 2017] *** 
compiled with version: 4.8.4 on 21 March 2017 14:56:34 
os: Linux-3.13.0-108-generiC#155-Ubuntu SMP Wed Jan 11 16:58:52 UTC 2017 
nodename: ip-172-31-9-49 
machine: x86_64 
clock source: unix 
detected number of CPU cores: 1 
current working directory: /home/ubuntu/webapps 
detected binary path: /usr/local/bin/uwsgi 
!!! no internal routing support, rebuild with pcre support !!! 
chdir() to /home/ubuntu/webapps/microbird 
your processes number limit is 7861 
your memory page size is 4096 bytes 
detected max file descriptor number: 1024 
lock engine: pthread robust mutexes 
thunder lock: disabled (you can enable it with --thunder-lock) 
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3 
Python version: 2.7.6 (default, Oct 26 2016, 20:33:43) [GCC 4.8.4] 
Set PythonHome to /home/ubuntu/webapps/env 
Python main interpreter initialized at 0x1353e80 
python threads support enabled 
your server socket listen backlog is limited to 100 connections 
your mercy for graceful operations on workers is 60 seconds 
mapped 218280 bytes (213 KB) for 2 cores 
*** Operational MODE: preforking *** 
Traceback (most recent call last): 
    File "microbird/wsgi.py", line 20, in <module> 
    from django.core.wsgi import get_wsgi_application 
ImportError: No module named django.core.wsgi 
unable to load app 0 (mountpoint='') (callable not found or import error) 
*** no app loaded. going in full dynamic mode *** 
*** uWSGI is running in multiple interpreter mode *** 
spawned uWSGI master process (pid: 21017) 
spawned uWSGI worker 1 (pid: 21018, cores: 1) 
spawned uWSGI worker 2 (pid: 21019, cores: 1) 
*** Stats server enabled on 127.0.0.1:9191 fd: 11 *** 

は〜

私runmicro.iniファイルが

[uwsgi] 
socket = 127.0.0.1:3031 
chdir = /home/ubuntu/webapps/microbird 
wsgi-file = microbird/wsgi.py 
processes = 2 
threads = 1 
stats = 127.0.0.1:9191 
virtualenv = /home/ubuntu/webapps/env 
plugin=python 
home = /home/ubuntu/webapps/env 

~ 
です

micro_nginxファイルが

server { 

     listen 80 default; 

     client_max_body_size 4G; 

     # server_name example.com www.example.com; 

     server_name microbird.in; 

     keepalive_timeout 5; 
     error_log /var/log/nginx/error.log; 
     #root /home/ubuntu/projects/textproject; 

     location/{ 

     include uwsgi_params; 

     uwsgi_pass 127.0.0.1:3031; 
     #proxy_pass http://127.0.0.1:8002; 
     } 

     location /static { 

     autoindex on; 

     alias /home/ubuntu/webapps/microbird/static; 

     } 
     location /media { 

       alias /home/ubuntu/webapps/microbird/media; 

     } 
} 

あるまあ、エラーが簡単ですどのように私は

+0

これは、nginxがvirtualenvの検索に問題があるようです。仮想環境への道は何ですか?ターミナルから手動で起動することができますか( 'source env/bin/activate')、開発サーバーでアプリケーションを実行しようとしますか?私はあなたのvirtualenvのパスがnginxの設定でオフになっていると思われる。 –

答えて

1

この問題を解決することができ、私を助けてください:

Traceback (most recent call last): 
    File "microbird/wsgi.py", line 20, in <module> 
    from django.core.wsgi import get_wsgi_application 
ImportError: No module named django.core.wsgi 

djangoは、あなたのPythonのではなく、モジュール検索パス。それがそうである理由を把握するために、私はあなたのwsgi.pyファイルにいくつかのデバッグコードを置くことを示唆している、ここではスタートだ:

import sys 

def application(environ, start_response): 
    status = '200 OK' 

    output = 'sys.path = %s\n' % repr(sys.path) 
    output += 'sys.version = %s\n' % repr(sys.version) 
    output += 'sys.prefix = %s\n' % repr(sys.prefix) 

    response_headers = [('Content-type', 'text/plain'), 
         ('Content-Length', str(len(output)))] 
    start_response(status, response_headers) 

    return [output] 

(あなたのsys.pathやあなたのPythonのいずれかがDjangoのない理由であるという仮定の下で見つけられる)。

virtualenvを使用する場合は、仮想化を有効にする必要があります。ここでは、私は(wsgi.pyファイルで)それを行う方法は次のとおりです。

VIRTUAL_ENV = '/path/to/root/of/virtualenv/' 
# activate virtualenv 
_activate = "%s/%s/activate_this.py" % (
    VIRTUAL_ENV, 
    'Scripts' if sys.platform == 'win32' else 'bin' 
) 
if sys.version_info >= (3, 0): 
    exec(compile(open(_activate, 'rb').read(), _activate, 'exec')) 
else: 
    execfile(_activate, dict(__file__=_activate)) 

私がどれだけのpython 3つの分岐作品(使用されていない)わかりません。

関連する問題