UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 98: invalid start byte
我在MacBookPro上运行https://github.com/tianyu0915/pythoner.net/来学习Django。
按照"读我"所说的操作完成后,当我运行应用程序时,控制台会说:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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 |
问题可能是这个模板文件。它不是UTF-8(似乎是GB2312),但模板引擎试图对其进行解码,从而导致错误。
把它转换成UTF-8,你应该很好——至少在这个问题上是这样。下一步将首先查明是什么导致了服务器错误。
也许你也应该在Github上提交一份bug报告。