好的,所以我在没有Virtualenv的情况下尝试了此操作:

uwsgi --home /home/auston/new_proj/ --socket /tmp/uwsgi2.sock --chmod-socket --module app_wsgi --pp /home/auston/new_proj/nikeshere --logto /tmp/uwsgi.log --master --processes 4 -P

几乎不管是什么,我明白了:

*** Starting uWSGI 0.9.6.5 (32bit) on [Thu Oct 21 08:05:44 2010] ***
compiled with version: 4.4.3
Python version: 2.6.6 (r266:84292, Oct 21 2010, 04:07:38)
[GCC 4.4.3]
your memory page size is 4096 bytes
allocated 412 bytes (0 KB) for 1 request's buffer.
Setting PythonHome to /home/auston/new_proj/...
binding on UNIX socket: /tmp/uwsgi2.sock
chmod() socket to 666 for lazy and brave users
your server socket listen backlog is limited to 64 connections
added /home/auston/new_proj/nikeshere to pythonpath.
initializing hooks...done.
['/home/auston/new_proj/nikeshere', '.', '', '/home/auston/new_proj/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg', '/home/auston/new_proj/lib/python2.6/site-packages/pip-0.8.1-py2.6.egg', '/home/auston/new_proj/lib/python26.zip', '/home/auston/new_proj/lib/python2.6', '/home/auston/new_proj/lib/python2.6/plat-linux2', '/home/auston/new_proj/lib/python2.6/lib-tk', '/home/auston/new_proj/lib/python2.6/lib-old', '/home/auston/new_proj/lib/python2.6/lib-dynload', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/home/auston/new_proj/lib/python2.6/site-packages', '/usr/local/lib/python2.6/dist-packages/pip-0.8.1-py2.6.egg', '/usr/local/lib/python2.6/site-packages', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/home/auston/new_proj/nikeshere', '/usr/local/lib/python2.6']
Traceback (most recent call last):
  File "/home/auston/new_proj/nikeshere/app_wsgi.py", line 11, in <module>
    import django.core.handlers.wsgi
  File "/usr/local/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 1, in <module>
    from threading import Lock
  File "/usr/lib/python2.6/threading.py", line 13, in <module>
    from functools import wraps
  File "/usr/lib/python2.6/functools.py", line 10, in <module>
    from _functools import partial, reduce
ImportError: No module named _functools

如果我更改-USR/local/lib/python/2.6我会在App_wsgi.py导入OS上失败。在下面,以防万一:

import sys
import os

sys.path.append(os.path.abspath(os.path.dirname(__file__)))

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

从本质上讲,我在问,如何让UWSGI识别功能或走正确的路径(在上方的输出中,路径已在上面)。感谢你们可以提供的任何帮助!!

PS Ubuntu 10.04 -UWSGI 0.9.6.5 -NGINX 0.8.53 -Virtual Env Python 2.6.5-“常规(或系统)” Python 2.6.6- django 1.2.3

更新:

如果我省略了“ - 模块”,我能够让UWSGI开始接受请求:

uwsgi --home /home/auston/new_proj --socket /tmp/uwsgi2.sock --chmod-socket --pp /home/auston/new_proj/nikeshere --logto /tmp/uwsgi.log --master --processes 4 -P

但是现在我发现一个未发现错误的应用程序:

“未找到的UWSGI错误WSGI应用程序”

我更加接近,但我仍然很感激建议,因为找不到该应用程序,因为我不能包括加载它所需的模块!

有帮助吗?

解决方案

因此,如上所述,问题是在PythonPath上,并且无法找到名为_Functools的模块。

显然,_functools是交流模块,我需要附加到PythonPath的路径才能找到它,因此与原始wsgi.py的差异现在为:

import sys
sys.path.append('/usr/local/lib/python2.6/lib-dynload') # to load _functools
sys.path.append('/usr/local/lib/python2.6/site-packages') # to load django
sys.path.append('/usr/local/lib/python2.6/dist-packages') # cautionary to load django
sys.path.append('/usr/lib/python2.6') # to load os
import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'iwin.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

非常骇人听闻,但现在起作用...

其他提示

我知道这是旧主题,堆栈构建块的版本更改了,但是我遇到了同样的问题,因为在Virtualenv中未识别在UWSGI下安装的libs。解决方案是将HOME参数指向Virtualenv,如下所示(取自 https://uwsgi.readthedocs.org/en/latest/tutorials/django_and_nginx.html).

因此,我的命令:

uwsgi --http :8000 --module ii.wsgi --home /home/dev/.virtualenvs/ii_env/

在Django应用程序(II)目录中工作时工作。

# mysite_uwsgi.ini file
[uwsgi]

# Django-related settings
# the base directory (full path)
chdir           = /path/to/your/project
# Django's wsgi file
module          = project.wsgi
# the virtualenv (full path)
home            = /path/to/virtualenv

# process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 10
# the socket (use the full path to be safe
socket          = /path/to/your/project/mysite.sock
# ... with appropriate permissions - may be needed
# chmod-socket    = 664
# clear environment on exit
vacuum          = true

查看 http://blog.zacharyvoase.com/2010/03/05/django-uwsgi-nginx/. 。他正在使用非常相似的设置。

我一直遇到非常相似的问题,我发现了这一点:

安装VirtuelEnv时,它通过与原始版本创建符号链接来“安装” Python标准库(在/usr/lib/python2.7中)。但是,当您查看Virtualenv Python Lib目录时,仅为几个基本库创建了符号链接。您的功能可能不在其中。

因此,解决方案是手动创建符号链接。这是一个PITA,因为您可能必须创建很多符号链接,但对我来说似乎是一个更干净的解决方案。您不必破解任何源文件,并且它是透明的。

符号链接不应在不在 venv_directory, ,但在例如

venv_directory/lib/python2.7/site-packages/

希望这对你有用!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top