Virtualenv无法接收

Virtualenv无法接收

本文介绍了uWSGI + Django + Virtualenv无法接收_functools(导入错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我用&没有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 

几乎无论如何,我得到这个:

  * **在[Thu Oct 21 08:05:44 2010] ***开始uWSGI 0.9.6.5(32bit)*** 
编译版本:4.4.3
Python版本:2.6.6(r266:84292 ,2010年10月21日,04:07:38)
[GCC 4.4.3]
您的内存页大小为4096字节
为1个请求的缓冲区分配了412个字节(0 KB)。
设置PythonHome到/ home / auston / new_proj / ...
在UNIX套接字上绑定:/tmp/uwsgi2.sock
chmod()套接字到666为懒惰和勇敢的用户
您的服务器套接字listen积压限制为64个连接
添加/ home / auston / new_proj / nikeshere到pythonpath。
初始化挂钩...完成。
['/ 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 /本地/ lib / python2.6 / dist-packages','/usr/lib/python2.6/dist-packages','/ home / auston / new_proj / nikeshere','/usr/local/lib/python2.6 ']
追溯(最近的最后一次呼叫):
文件 /home/auston/new_proj/nikeshere/app_wsgi.py,第11行在< module>
import django.core.handlers.wsgi
文件/usr/local/lib/python2.6/site-packages/django/core/handlers/wsgi.py,第1行,模块>
从线程导入Lock
文件/usr/lib/python2.6/threading.py,第13行,< module>
从functools import fraps
文件/usr/lib/python2.6/functools.py,第10行在< module>
来自_functools import partial,reduce
ImportError:没有名为_functools的模块

如果我改变了--home到/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认识functools或得到正确的路径(路径在输出上面)。我会感谢你们可以给予的任何帮助。



P.S。 Ubuntu 10.04 - uWSGI 0.9.6.5 - NGINX 0.8.53 - 虚拟环境Python 2.6.5 - 常规(或系统)Python 2.6.6 - Django 1.2.3



更新:



如果我省略--module,我可以让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是一个c模块和我需要将它的路径附加到pythonpath,以便找到它,所以与原始wsgi.py的区别现在是:

  import sys 
sys.path.append('/ usr / local / lib / python2.6 / lib-dynload')#加载_functools
sys.path.append('/ usr / local / lib / python2.6 / site-packages')#加载django
sys.path.append('/ usr / local / lib / python2.6 / dist-packages')#警告加载django
sys.path.append('/ usr / lib / python2.6')#加载os
import os

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

import django.core.handlers.wsgi

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

非常黑客,但现在适用...


OK, So I have tried this with & without a 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

Pretty much no matter what, I get this:

*** 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

If I change --home to /usr/local/lib/python/2.6 I get fail on my app_wsgi.py import of os. Here it is, below, just in case:

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()

Essentially I am asking, how can I get uWSGI to recognize functools OR get on the right path (path is in output above). I would appreciate any help you guys can give!!

P.S. Ubuntu 10.04 - uWSGI 0.9.6.5 - NGINX 0.8.53 - virtual env Python 2.6.5 - "regular (or system)" Python 2.6.6 - Django 1.2.3

UPDATE:

I was able to get uwsgi to start accepting requests if I omit the "--module" like so:

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

but now I get a app not found error:

"uWSGI Errorwsgi application not found"

I'm closer but I would still appreciate suggestions as the app is not found because i cannot include the module needed to load it!

解决方案

So as noted above, the problem has been with the pythonpath & it's inability to find a module named _functools.

Apparently, _functools is a c module & I needed to append the it's path to the pythonpath in order for it to be found, so the difference from the original wsgi.py, is now:

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()

Very hacky, but it works for now...

这篇关于uWSGI + Django + Virtualenv无法接收_functools(导入错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 10:14