gethostbyaddr()在Python 3中引发UnicodeDecodeError

时间:2014-09-20 12:19:52

标签: python django

我正在尝试使用Python 3.4.1构建一个Django项目。 manage.py runserver引发UnicodeDecodeException。

如何解决这个问题?请参阅下面(修剪过的)回溯:

Traceback (most recent call last):
  File "C:\Python34\lib\socketserver.py", line 429, in __init__
    self.server_bind()
  File "C:\Python34\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 460, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 12: invalid
 continuation byte

每个请求,我的主机名:

C:\Users\AnatoliyVik>hostname
AnatoliyVik-ПК

1 个答案:

答案 0 :(得分:1)

将主机名更改为不再包含西里尔符号可以解决问题。

感谢@Lafada的指导。