uwsgi + python2.7 unable to import anything
I'm trying to use uwsgi + python2.7 + django + nginx on debian 6. I installed uwsgi with the command: pip2.7 install uwsgi
so it's running with python 2.7. I'm running uwsgi in emperor mode with the command: uwsgi --emperor /etc/uwsgi/vassals/ -d /var/log/uwsgi.log --pidfile /var/run/uwsgi.pid
The vassals folder contains only one app for the moment. Here is it's yaml file:
uwsgi:
socket: /home/uwsgi/uwsgi/uwsgi.sock
virtualenv: /opt/myproj/virt
pythonpath: /home/uwsgi/project/my_proj
pidfile: /home/uwsgi/uwsgi/uwsgi.pid
uid: uwsgi
gid: uwsgi
chmod-socket: 1
module: wsgi_app
daemonize: /home/uwsgi/uwsgi/uwsgi.log
harakiri-verbose: 1
This is the content of the Django project file:
#! /usr/bin/python
SITE_DIR = '/home/uwsgi/project/my_proj'
import site
site.addsitedir(SITE_DIR)
import os
import sys
sys.path.append(SITE_DIR)
sys.path.append('/home/uwsgi/project/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'my_proj.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Now, here is the result in the /home/uwsgi/uwsgi/uwsgi.log file when I try to launch it:
*** Starting uWSGI 1.0.4 (32bit) on [Fri Mar 2 19:00:46 2012] ***
compiled with version: 4.6.2 on 02 March 2012 18:03:07
current working directory: /etc/uwsgi/vassals
writing pidfile to /home/uwsgi/uwsgi/uwsgi.pid
detected binary path: /usr/local/bin/uwsgi
setgid() to 1001
setuid() to 1001
your memory page size is 4096 bytes
chmod() socket to 666 for lazy and brave users
uwsgi socket 0 bound to UNIX address /home/uwsgi/uwsgi/uwsgi.sock fd 3
Python version: 2.7.2+ (default, Dec 1 2011, 02:17:49) [GCC 4.6.2]
Set PythonHome to /opt/myproj/virt
ImportError: No module named site
*** Starting uWSGI 1.0.4 (32bit) on [Fri Mar 2 19:00:47 2012] ***
compiled with version: 4.6.2 on 02 March 2012 18:03:07
current working directory: /etc/uwsgi/vassals
writing pidfile to /home/uwsgi/uwsgi/uwsgi.pid
detected binary path: /usr/local/bin/uwsgi
setgid() to 1001
setuid() to 1001
your memory page size is 4096 bytes
chmod() socket to 666 for lazy and brave users
uwsgi socket 0 bound to UNIX address /home/uwsgi/uwsgi/uwsgi.sock fd 3
Python version: 2.7.2+ (default, Dec 1 2011, 02:17:49) [GCC 4.6.2]
Set PythonHome to /opt/myproj/virt
ImportError: No module named site
As you can see, uwsgi can't import the site module so uwsgi keeps trying to restart the app. So I tried to add the no-site :1 option in the yaml file. The result is that I can't import anything in my Django project file...
I also know it's not linked to the project because if I run uwsgi with python 2.6, it just works fine... Unfortunally, I have to run it with python2.7...
Do you have any idea what happens ?
Thanks a lot!
Be sure your virtualenv is built for python2.7, otherwise it cannot be used.
It has to contains /opt/myproj/virt/lib/python2.7 directory
链接地址: http://www.djcxy.com/p/65930.html