Skip to main content
 首页 » 编程设计

python之无法创建内存 View ,因为对象没有缓冲区接口(interface)

2025年05月04日13duanxz

我正在使用 django 1.3.1 和 python 2.7 实现一个应用。

此应用使用 Facebook 登录,但我收到此错误消息:

TypeError at /promo-racao/ 
cannot make memory view because object does not have the buffer interface 

奇怪的是它在本地有效。这个错误只发生在webserver上,但是环境是一样的。而且它不指向特定的文件或代码行。

在 Google 上搜索此错误不会返回任何有用的信息。这是我从 Django 得到的回溯:

Environment: 
 
 
Request Method: GET 
Request URL: http://dev.muccacompany.com/promo-racao/?code=<my code - yes, I modified this part> 
 
Django Version: 1.3.1 
Python Version: 2.7.1 
Installed Applications: 
['django.contrib.auth', 
 'django.contrib.contenttypes', 
 'django.contrib.sessions', 
 'django.contrib.admin', 
 'south', 
 'mucca_apps.social', 
 'djcelery', 
 'mailing', 
 'muitter', 
 'customer', 
 'finance', 
 'blogs', 
 'web', 
 'social', 
 'gunicorn', 
 'so_desconto', 
 'djcelery', 
 'partner', 
 'tracking'] 
Installed Middleware: 
('django.middleware.common.CommonMiddleware', 
 'django.contrib.sessions.middleware.SessionMiddleware', 
 'django.contrib.auth.middleware.AuthenticationMiddleware', 
 'tracking.middleware.TrackingMiddleware') 
 
 
Traceback: 
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 
  111.                         response = callback(request, *callback_args, **callback_kwargs) 
File "/home/mucca/git/deploy/muccadev/app/views.py" in home 
  24.         return participar(request, code) 
File "/home/mucca/git/deploy/muccadev/app/views.py" in participar 
  33.         fb_profile = get_or_create_fbprofile(request, redirect_url) 
File "/home/mucca/git/deploy/muccadev/app/helpers.py" in get_or_create_fbprofile 
  16.     token = fb_auth.app_auth(request) 
File "/home/mucca/git/deploy/muccadev/mucca_apps/social/helpers.py" in app_auth 
  52.             response = urllib2.urlopen(req) 
File "/usr/lib/python2.7/urllib2.py" in urlopen 
  126.     return _opener.open(url, data, timeout) 
File "/usr/lib/python2.7/urllib2.py" in open 
  392.         response = self._open(req, data) 
File "/usr/lib/python2.7/urllib2.py" in _open 
  410.                                   '_open', req) 
File "/usr/lib/python2.7/urllib2.py" in _call_chain 
  370.             result = func(*args) 
File "/usr/lib/python2.7/site-packages/poster/streaminghttp.py" in https_open 
  170.             return self.do_open(StreamingHTTPSConnection, req) 
File "/usr/lib/python2.7/urllib2.py" in do_open 
  1155.             h.request(req.get_method(), req.get_selector(), req.data, headers) 
File "/usr/lib/python2.7/httplib.py" in request 
  941.         self._send_request(method, url, body, headers) 
File "/usr/lib/python2.7/httplib.py" in _send_request 
  975.         self.endheaders(body) 
File "/usr/lib/python2.7/httplib.py" in endheaders 
  937.         self._send_output(message_body) 
File "/usr/lib/python2.7/httplib.py" in _send_output 
  801.             self.send(message_body) 
File "/usr/lib/python2.7/site-packages/poster/streaminghttp.py" in send 
  81.                 self.sock.sendall(value) 
File "/usr/lib/python2.7/site-packages/gevent-0.13.3-py2.7-linux-i686.egg/gevent/socket.py" in sendall 
  510.                 data_sent += self.send(_get_memory(data, data_sent), flags, timeout=timeleft) 
File "/usr/lib/python2.7/site-packages/gevent-0.13.3-py2.7-linux-i686.egg/gevent/socket.py" in _get_memory 
  261.         return memoryview(string)[offset:] 
 
Exception Type: TypeError at /promo-racao/ 
Exception Value: cannot make memory view because object does not have the buffer interface 

请您参考如下方法:

这是 gevent 中的一个错误。它已在 0.13.7 中修复。只需升级 gevent,你应该没问题。请参阅:http://www.gevent.org/changelog.html