UnicodeDecodeError在启动用th创建的全新Django项目时出错

2024-04-20 02:08:48 发布

您现在位置:Python中文网/ 问答频道 /正文

更新:我将Python3.4降级为3.3.5,因此Django与之兼容,但问题仍然存在:

我对python和django非常了解,我在Windows笔记本电脑中安装了python3.3.5和django 1.6.6。我遵循django教程,但我被困在第二步,因为我得到一个错误。你知道吗

我创建了这个项目:

django-admin startproject TouristGuide

然后我进入了创建的文件夹旅游指南在哪里管理.py位于

cd TouristGuide

然后我启动服务器,就像教程建议的那样:

python manage.py runserver

当我执行该行时,我得到以下错误:

Validating models...

0 errors found
September 01, 2014 - 23:11:07
Django version 1.6.6, using settings 'TouristGuide.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 0x02B4E9C0>
Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\django\utils\autoreload.py", line 93, in w
rapper
    fn(*args, **kwargs)
  File "C:\Python33\lib\site-packages\django\core\management\commands\runserver.
py", line 128, in inner_run
    ipv6=self.use_ipv6, threading=threading)
  File "C:\Python33\lib\site-packages\django\core\servers\basehttp.py", line 167
, in run
    httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
  File "C:\Python33\lib\site-packages\django\core\servers\basehttp.py", line 109
, in __init__
    super(WSGIServer, self).__init__(*args, **kwargs)
  File "C:\Python33\lib\socketserver.py", line 430, in __init__
    self.server_bind()
  File "C:\Python33\lib\site-packages\django\core\servers\basehttp.py", line 113
, in server_bind
    super(WSGIServer, self).server_bind()
  File "C:\Python33\lib\wsgiref\simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "C:\Python33\lib\http\server.py", line 137, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\Python33\lib\socket.py", line 386, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 4: invalid
continuation byte

Tags: djangoinpycoreselfserverbindlib
2条回答

我希望我能把这个放在评论里,但我还没有足够的声誉。根据文档,Django1.6不支持Python3.4。阅读FAQ了解详细信息。您需要将Python降级到3.3或将Django升级到1.7。你知道吗

问题是我的笔记本电脑的名称是“Portátil”,当python使用gethostbyaddr时,它的响应就是这个名称,而python似乎没有正确处理编码。我已经更改了笔记本的名称,所以现在它不包含任何重音字符。你知道吗

相关问题 更多 >