2

When I run django project in pycharm or cmd, I get this error. What Should I do?

"C:\Program Files (x86)\JetBrains\PyCharm 3.4.1\bin\runnerw.exe" C:\Python34\python.exe C:/Users/admin/PycharmProjects/untitled/manage.py runserver 8000 Validating models...

0 errors found
August 15, 2014 - 13:58:27
Django version 1.6.5, using settings 'untitled.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 0x022A32B8>
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 429, 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 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 6: invalid continuation byte
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • This looks a little bit like [Issue18109](http://bugs.python.org/issue18109) for me, but that should be solved... Does your hostname contain unicode characters? – flammi88 Aug 15 '14 at 12:17

3 Answers3

0

1) Check your settings.py manage.py wsgi.py etc. for the non-ascii literals.

2) When found add

# -*- coding: utf-8 -*-

at the beginning of your files

3) And add u at the beggining of strings that contains non-ascii literals

eg: u"This characters are not unicode : üşiğç"

///for python 2.x

obayhan
  • 1,636
  • 18
  • 35
0

I have not tested it, but I suppose this is a python error. The stack trace you have provided suggests, that the UnicodeDecodeError gets triggerd when your hostname gets copied into a python unicode string.

Please check if the hostname of the machine you are working on contains unicode characters.

This seems to be the same issue as yours. In the post the python Issue9377 is referenced which is still open.

Community
  • 1
  • 1
flammi88
  • 381
  • 2
  • 14
0

Try to verify host name. Migth be your host name contains some non-ascii literals. Seems that you use Windows 7 OS.

Yury Staravoitau
  • 175
  • 5
  • 11