简体   繁体   中英

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 0: invalid continuation byte

I start my Django project, migrate my databases, and after there I run my server for testing.

If I run the server in my Django project in Python...

(venv) C:\PR\djangogirls>manage.py runserver

Performing system checks...
System check identified no issues (0 silenced).
April 03, 2015 - 00:59:05
Django version 1.7.7, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK

I get this error:

System check identified no issues (0 silenced).
April 03, 2015 - 00:59:05
Django version 1.7.7, using settings 'mysite.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 0x00000000045897B8>
Traceback (most recent call last):
  File "C:\PR\djangogirls\venv\lib\site-packages\django\utils\autoreload.py", li
ne 222, in wrapper
    fn(*args, **kwargs)
  File "C:\PR\djangogirls\venv\lib\site-packages\django\core\management\commands
\runserver.py", line 134, in inner_run
    ipv6=self.use_ipv6, threading=threading)
  File "C:\PR\djangogirls\venv\lib\site-packages\django\core\servers\basehttp.py
", line 176, in run
    httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
  File "C:\PR\djangogirls\venv\lib\site-packages\django\core\servers\basehttp.py
", line 117, in __init__
    super(WSGIServer, self).__init__(*args, **kwargs)
  File "C:\Python34\lib\socketserver.py", line 430, in __init__
    self.server_bind()
  File "C:\PR\djangogirls\venv\lib\site-packages\django\core\servers\basehttp.py
", line 121, in server_bind
    super(WSGIServer, self).server_bind()
  File "C:\Python34\lib\wsgiref\simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "C:\Python34\lib\http\server.py", line 135, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\Python34\lib\socket.py", line 464, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 0: invalid continuation byte

How do I fix this error?

It may be a problem with your computer name, not the user's name. I have experienced the same problem before. After I changed the computer name to an English name the problem was resolved. I think the issue is the name of the port. When my computer's name is '书房台式计算机 ',, Django reads the port as '书房计算机:8000 ' and reports an error.

When I changed the computer name to 'Gaara ' the port's name changed to 'Gaara:8000' and didn't return an error.

您可以尝试通过笔记本打开源文件,选择文件编码:UTF-8,然后将文件另存为新文件。重新加载新文件即可解决此错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM