please help me about django error that encoding is wrong

已查看 46 次
跳至第一个未读帖子

輝夜三日月

未读,
2017年8月22日 07:34:552017/8/22
收件人 Django users

just create a django project in Pycharm which was in a virtual environment ,while it send me a unsolved problem about following things:



"C:\Program Files\JetBrains\PyCharm 2017.2.1\bin\runnerw.exe" C:\Users\Administrator\sample——venv\Scripts\python.exe C:/Users/Administrator/PycharmProjects/untitle7/manage.py runserver 8000
Performing system checks...

System check identified some issues:

WARNINGS:
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS.

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


just a empty project,I have done nothing but receive so many errors.I try to find some methods to solve it in starkflow or somewhere but,just find a unsolved question.

Vijay Khemlani

未读,
2017年8月22日 07:49:522017/8/22
收件人 django...@googlegroups.com
What is the hostname of your machine? If you are using Windows then you can execute "ipconfig /all" on a cmd prompt

--
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...@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/a5580eb5-2b2b-4207-becb-65e183144f2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Schneider

未读,
2017年8月22日 12:35:302017/8/22
收件人 django...@googlegroups.com

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

回复全部
回复作者
转发
0 个新帖子