本人系统win10 64位,python 3.5,在建立网站项目时运行python manage.py runserver报错:
System check identified no issues (0 silenced).
August 10, 2017 - 19:10:22
Django version 1.11.4, using settings 'myblog.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 0x036D74F8>
Traceback (most recent call last):
File "C:\python3\lib\site-packages\django\utils\autoreload.py", line 228, in w
rapper
fn(*args, **kwargs)
File "C:\python3\lib\site-packages\django\core\management\commands\runserver.p
y", line 149, in inner_run
ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)
File "C:\python3\lib\site-packages\django\core\servers\basehttp.py", line 164,
in run
httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
File "C:\python3\lib\site-packages\django\core\servers\basehttp.py", line 74,
in __init__
super(WSGIServer, self).__init__(*args, **kwargs)
File "C:\python3\lib\socketserver.py", line 453, in __init__
self.server_bind()
File "C:\python3\lib\wsgiref\simple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "C:\python3\lib\http\server.py", line 138, in server_bind
self.server_name = socket.getfqdn(host)
File "C:\python3\lib\socket.py", line 673, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 2: invalid
continuation byte
看到这个我呵呵了,我仍然试着打开http://127.0.0.1:8000/ ,浏览器告诉我无法访问。百度说我没打开IIS管理器,好吧,我确实没打开,然而打开后还是无法访问(在打开iis的过程中,还遇到0x80070057,网上说是net版本与win10兼容的问题,于是,我下载了个最新版的net。重新安装iis,这是这一次我只勾选了web管理工具,安装成功)。我就在考虑是不是最后一行的编码问题,然而根据网上的回答,大多是换个python版本或者是用linux系统,本来都快放弃了。
最后查到“一般来说编码错误是由中文引起的。从 traceback 最后一栈落在 gethostbyaddr 上可以看出:你电脑的主机名多半是设成了中文了。”这句话,于是将我的计算机全名改成英文,于是got it。