回到顶部

Contents

django runserver: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

windows 下,django runserver 时报错:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

(venv) E:\Program Files (x86)\Git\workspace\dingzhi\dzPython\web\demo>python manage.py runserver 127.0.0.1:8000
Performing system checks...

System check identified no issues (0 silenced).

You have 14 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
May 25, 2020 - 20:00:55
Django version 2.0, using settings 'demo.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Exception ignored in thread started by: <function check_errors.<locals>.wrapper at 0x000001A30091E430>
Traceback (most recent call last):
  File "E:\Program Files (x86)\Git\workspace\dingzhi\dzPython\web\venv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "E:\Program Files (x86)\Git\workspace\dingzhi\dzPython\web\venv\lib\site-packages\django\core\management\commands\runserver.py", line 141, in inner_run
    run(self.addr, int(self.port), handler,
  File "E:\Program Files (x86)\Git\workspace\dingzhi\dzPython\web\venv\lib\site-packages\django\core\servers\basehttp.py", line 163, in run
    httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
  File "E:\Program Files (x86)\Git\workspace\dingzhi\dzPython\web\venv\lib\site-packages\django\core\servers\basehttp.py", line 66, in __init__
    super().__init__(*args, **kwargs)
  File "e:\python\lib\socketserver.py", line 452, in __init__
    self.server_bind()
  File "e:\python\lib\wsgiref\simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "e:\python\lib\http\server.py", line 140, in server_bind
    self.server_name = socket.getfqdn(host)
  File "e:\python\lib\socket.py", line 756, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

很可能的原因你的是 电脑名称(计算机名称)含有中文,我们需要把含有中文计算机名称改成全英文的,然后重启电脑再次 runserver.

 

^_^
请喝咖啡 ×

前一篇: django-haystack 让检索结果开头不缩略显示(完全显示)
下一篇: pycharm 默认模版 File and Code Templates
captcha