2013-09-26 64 views
1

我在MacBookPro上运行https://github.com/tianyu0915/pythoner.net/以学习django。UnicodeDecodeError:'utf8'编解码器无法解码位置98中的字节0xb4:无效起始字节

完成后为念我说,当我跑的应用程序,控制台说:

 
Traceback (most recent call last): 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run 
    self.result = application(self.environ, self.start_response) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__ 
    return self.application(environ, start_response) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__ 
    response = self.get_response(request) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/core/handlers/base.py", line 179, in get_response 
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception 
    return callback(request, **param_dict) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view 
    response = view_func(request, *args, **kwargs) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/views/defaults.py", line 32, in server_error 
    t = loader.get_template(template_name) # You need to create a 500.html template. 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/template/loader.py", line 145, in get_template 
    template, origin = find_template(template_name) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/template/loader.py", line 134, in find_template 
    source, display_name = loader(name, dirs) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/template/loader.py", line 42, in __call__ 
    return self.load_template(template_name, template_dirs) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/template/loader.py", line 45, in load_template 
    source, display_name = self.load_template_source(template_name, template_dirs) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/site-packages/django/template/loaders/filesystem.py", line 39, in load_template_source 
    return (file.read().decode(settings.FILE_CHARSET), filepath) 
    File "/Users/keviswang/.virtualenvs/pythoner/lib/python2.7/encodings/utf_8.py", line 16, in decode 
    return codecs.utf_8_decode(input, errors, True) 
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 98: invalid start byte 

回答

1

这个问题可能是this template file。它不是utf-8(似乎是GB2312),但模板引擎试图解码它,因此导致错误。

把它转换为utf-8,你应该很好 - 至少对于这部分问题。下一步将首先找出造成服务器错误的原因。

也许你还应该在github上提交一个bug报告。

+0

谢谢,我想知道如何在这种情况下找到这个文件? – Keviswang

+0

在这种情况下''你需要创建一个500.html模板'这条线索......但通常你需要通过stacktrace中提到的源代码行来找出发生了什么。 – mata

相关问题