这个问题要求保存时间。我尝试了所有的东西,但我无法解决这个错误。我正在使用nginx部署我的django应用程序,但收到此错误。 我的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 :(得分: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分支的工作情况(从未使用过)。