uwsgi + python2.7无法导入任何内容
我试图在debian 6上使用uwsgi + python2.7 + django + nginx。我使用下面的命令pip2.7 install uwsgi
: pip2.7 install uwsgi
所以它使用python 2.7运行。 我使用以下命令在皇帝模式下运行uwsgi:uwsgi --emperor / etc / uwsgi / vassals / -d /var/log/uwsgi.log --pidfile /var/run/uwsgi.pid
vassals文件夹目前只包含一个应用程序。 这是它的yaml文件:
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
这是Django项目文件的内容:
#! /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()
现在,下面是我尝试启动时在/home/uwsgi/uwsgi/uwsgi.log文件中的结果:
*** 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
如您所见,uwsgi无法导入站点模块,因此uwsgi不断尝试重新启动应用程序。 所以我试图在yaml文件中添加no-site:1选项。 结果是我不能在我的Django项目文件中导入任何内容......
我也知道它没有链接到该项目,因为如果我用python 2.6运行uwsgi,它可以正常工作......不幸的是,我必须使用python2.7来运行它...
你有什么想法会发生什么?
非常感谢!
确保你的virtualenv是为python2.7构建的,否则它不能使用。
它必须包含/opt/myproj/virt/lib/python2.7目录
链接地址: http://www.djcxy.com/p/65929.html上一篇: uwsgi + python2.7 unable to import anything
下一篇: Google Maps & JavaFX: Display marker on the map after clicking JavaFX button