如何修复 UnicodeDecodeError:'utf-8'编解码器无法解码位置 5 中的字节0xcf:无效的延续字节



我正试图在服务器上运行一个新创建的环境,并获取UnicodeDecodeError。

Windows 7,64位。我已经创建了一个虚拟环境,并将代码定向到源文件夹。以下是安装的django、python和virtualenv版本。我试过安装django和python的旧版本,但也出现了同样的错误。

在搜索故障排除建议时,我只找到与.csv和panda相关的文章。

Django==2.2.7
pytz==2019.3
virtualenv==16.7.7
PS: C:UsersUserDevSelectiasrc> python manage.py runserver

这是输出:

Watching for file changes with StartReloader
Performing system checks...
System checkidentified no issues (0 silenced).
November 05, 2019 - 12:02:31
Django version 2.2.7, using setings 'foodie.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREALK.
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:UsersUserAppDataLocalProgramsPythonPython37libthreading.py", line 917, in _bootstrap_inner
self.run()
File "C:UsersUserAppDataLocalProgramsPythonPython37libthreading.py", line 865, in run
self._target(*self.args, **self._kwargs)
File "C:UsersUserAppDataLocalProgramsPythonPython37libsite-packagesdjangoutilsautoreload.py", line 54 in wrapper 
fn(*args, **kwargs)
File "C:UsersUserAppDataLocalProgramsPythonPython37libsite-packagesdjangocoreserversbasehttp.py", line 203, in run
httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
File "C:UsersUserAppDataLocalProgramsPythonPython37libsite-packagesdjangocoreserversbasehttp.py", line 67, in __init__
super().__init__(*args, **kwargs)
File "C:UsersUserAppDataLocalProgramsPythonPython37libsocketserver.py", line 452, in __init__
self.server_bind()
File "C:UsersUserAppDataLocalProgramsPythonPython37libwsgirefsimple_server.py", line 50, in server_bind
HTTPServer.server_bind(self)
File "C:UsersUserAppDataLocalProgramsPythonPython37libhttpserver.py", line 139, in server_bind
self.server_name = socket.getfqdn(host)
File "C:UsersUserAppDataLocalProgramsPythonPython37libsocket.py", line 676, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecoderError: 'utf-8' code can't decode byte 0xcf in position 5: invalid continuation byte

你能帮我找出如何处理这个错误消息的方法吗?

第页。S.这是我的第一个web框架项目,我对python有一些了解。如果能提供任何帮助,我将不胜感激。我想建立自己的网站。

主机文件中有别名,其中包含无法解码为UTF-8的字符。删除它们以解决问题(可能最简单的方法是使任何别名仅为ASCII(。

Windows 7上主机文件的默认位置是

C:WindowsSystem32Driversetchosts

相关内容

最新更新