Tuesday, August 22, 2017

Re: please help me about django error that encoding is wrong


System check identified 1 issue (0 silenced).
August 22, 2017 - 02:05:59
Django version 1.11.4, using settings 'untitle7.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03827030>
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 149, in inner_run
    ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 164, in run
    httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 74, in __init__
    super(WSGIServer, self).__init__(*args, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Lib\socketserver.py", line 453, in __init__
    self.server_bind()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Lib\wsgiref\simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Lib\http\server.py", line 138, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Lib\socket.py", line 673, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 0: invalid start byte


I'm going to take a stab in the dark. From the traceback, it appears Django is trying to resolve the name of the host where you are running the development server, but the byte string it is getting back from the system calls querying the host name of your computer is not encoded using UTF-8 (or is getting a character string that is not being properly encoded), hence the decode errors. 


There are also a bunch of references to this (Still open from 2010) Python bug: http://bugs.python.org/issue9377 (socket, PEP 383: Mishandling of non-ASCII bytes in host/domain names)

Try changing the name of your computer to use only ASCII characters (which should work around the encoding/decoding issues). If that works, I'm not entirely sure what the long-term solution is, but that should at least point you in the right direction when Googling.

-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXzgFFaar6HU6JTshg5SP-k03xs9EkOAWmvwtZaLkXmgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment