我已经在CentOS上安装了Python2.7,并使用以下命令为我的项目创建了一个虚拟环境:
$ virtualenv -p /usr/local/bin/python2.7 venv我已经安装了uwsgi,并禁用了virtualenv。
我还安装了uwsgi-plugin-python,因为我遇到了‘请求不可用修改器:’的问题。
nginx配置:
upstream django {
server unix:///tmp/mysite.sock; # for a file socket
}
server {
listen 80;
server_name mysite;
charset utf-8;
client_max_body_size 75M; # adjust to taste
location /media {
alias /projects/mysite/media;
}
location /static {
alias /projects/rebus/rebus/static;
}
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params;
}
}uwsgi ini文件:
[uwsgi]
chdir = /projects/mysite
module = mysite.wsgi
virtualenv = /projects/mysite/venv
plugin = python
master = true
processes = 2
socket = /tmp/mysite.sock
chmod-socket = 664
vacuum = true现在,当我启动它并尝试访问网站时:
uwsgi --ini mysite_uwsgi.ini我得到以下日志:
*** Starting uWSGI 2.0.11.1 (64bit) on [Wed Aug 19 12:01:22 2015] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-11) on 21 July 2015 15:58:54
os: Linux-2.6.32-042stab084.12 #1 SMP Tue Nov 26 20:18:08 MSK 2013
nodename: vs23.wovz.net
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 8
current working directory: /var/run
detected binary path: /usr/sbin/uwsgi
chdir() to /projects/mysite
your processes number limit is 1024
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 UNIX address /tmp/mysite.sock fd 3
Python version: 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
Set PythonHome to /projects/mysite/venv
'import site' failed; use -v for traceback
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x12e7160
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 218304 bytes (213 KB) for 2 cores
*** Operational MODE: preforking ***
Traceback (most recent call last):
File "./mysite/wsgi.py", line 10, in <module>
import os
ImportError: No module named os
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: 1106)
spawned uWSGI worker 1 (pid: 1107, cores: 1)
spawned uWSGI worker 2 (pid: 1108, cores: 1)
--- no python application found, check your startup logs for errors ---看起来我的Python2.7的virtualenv无法识别,UWSGI无法加载我的Django应用程序。我怎么才能修复它呢?
发布于 2017-01-05 01:26:50
这也可能与针对哪个版本的Python uwsgi进行编译有关。如果您使用--python=python3创建虚拟环境,但使用通过pip install uwsgi而不是pip3 install uwsgi获得的uwsgi,那么您将在默认Python2.7的系统上看到相同的症状('import site' failed)。
发布于 2016-10-12 15:54:38
也许你没有在你的虚拟环境中安装uwsgi模块
解决方案:
source /projects/mysite/venv/bin/activate
pip install uwsgi 然后重新运行您的uwsgi服务器,它可能会工作。
https://stackoverflow.com/questions/32117949
复制相似问题