django创建项目Python manage.py runserver报错

这里是报错,我是在官网下载django然后只做一少部分的操作,但是UnicodeDecodeError到底我在哪里用到ascii???为什么会报错?

Performing system checks...

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

myblog urls.py中只是按这种格式写入(include是后来改的,但之前形式和第一行相同,也删过r,也将u代替过r都没有用)
clipboard.png

clipboard.png

阅读 5.6k
1 个回答

这是一个罕见的问题...

一般来说编码错误是由中文引起的。从 traceback 最后一栈落在 gethostbyaddr 上可以看出:你电脑的主机名多半是设成了中文了

计算机->右键->属性:

clipboard.png

如果此处是中文,把他改成英文

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进