一尘不染

Unicodedecodeerror with runserver

django

设置所有django要求后,我尝试了该runserver命令,但发现了一个错误:

UnicodeDecodeError:’utf-8’编解码器无法解码位置8的字节0xcf:无效的继续字节

从:

c:\sue>python manage.py runserver
Validating models...

0 errors found
April 16, 2014 - 15:02:42
Django version 1.6.2, using settings 'sue.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 0x0000000003890048>
Traceback (most recent call last):
  File "C:\python34\lib\site-packages\django\utils\autoreload.py", line 93, in wrapper fn(*args, **kwargs)
  File "C:\python34\lib\site-packages\django\core\management\commands\runserver.py", line 127, in inner_run ipv6=self.use_ipv6, threading=threading)
  File "C:\python34\lib\site-packages\django\core\servers\basehttp.py", line 167, in run httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
  File "C:\python34\lib\site-packages\django\core\servers\basehttp.py", line 109, in __init__ super(WSGIServer, self).__init__(*args, **kwargs)
  File "C:\python34\lib\socketserver.py", line 430, in __init__ self.server_bind()
  File "C:\python34\lib\site-packages\django\core\servers\basehttp.py", line 113, 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 137, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\python34\lib\socket.py", line 460, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 8: invalid continuation byte

我正在使用Windows 7 x64,python 3.4和Django 1.6.2。这个错误是什么意思?


阅读 337

收藏
2020-03-28

共1个答案

一尘不染

这听起来像是Python问题。如果你的计算机名称包含非ASCII字符,则此操作将失败。你可以:

  1. 发出带有显式主机和端口的runserver命令: python manage.py runserver 127.0.0.1:8000
  2. 将你的计算机名称更改为仅包含ASCII字符的字符串。
2020-03-28