[求助]Windows下基于python3.5_64位,运行django,runserver出错

Chris_D 发布于 2015年11月22日
tinyfool 等1人欣赏。 1人反对。

Windows下基于python3.5_64位,运行django,runserver出错

今天尝试在windows下搭建个人网站,选用了python3.5+django

安装了python3.5的64位版本,用pip install安装了django

运行python .manage.py runserver报错,提示错误如下:

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x000000000416A7B8>
Traceback (most recent call last):
File "F:Python3.5_64libsite-packagesdjangoutilsautoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "F:Python3.5_64libsite-packagesdjangocoremanagementcommandsrunserver.py", line 143, in inner_run
ipv6=self.use_ipv6, threading=threading)
File "F:Python3.5_64libsite-packagesdjangocoreserversbasehttp.py", line 191, in run
httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
File "F:Python3.5_64libsite-packagesdjangocoreserversbasehttp.py", line 76, in __init__
super(WSGIServer, self).__init__(*args, **kwargs)
File "F:Python3.5_64libsocketserver.py", line 443, in __init__
self.server_bind()
File "F:Python3.5_64libsite-packagesdjangocoreserversbasehttp.py", line 80, in server_bind
super(WSGIServer, self).server_bind()
File "F:Python3.5_64libwsgirefsimple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "F:Python3.5_64libhttpserver.py", line 140, in server_bind
self.server_name = socket.getfqdn(host)
File "F:Python3.5_64libsocket.py", line 658, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 0: invalid start byte

主要看出来两个熟悉的词,一个是IPv6,还有一个是UTF-8,但是不知道具体问题出在哪里。怀疑是不能使用ipv6,或者之类的错误。stack overflow上貌似有个类似的情况,但是刷不出来网页。

求助各位大神,帮忙解决一下。

第一次用ourcoders提问,请大家指正。

共1条回复
Chris_D 回复于 2015年11月22日

自己找到了解决方案:

把runserver的指令换成

python .manage.py runserver 127.0.0.2:8000

然后就可以了,但是实在搞不清楚原因,不知道有没有谁能解答一下。

这个是我自己试出来的,试了好几种ip+端口,忽然有一个就成功了。真是意外。

登录 或者 注册
相关帖子