Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that gethostbyaddr triggers UnicodeDecodeError in Python3

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to solve UnicodeDecodeError caused by gethostbyaddr in Python3". In daily operation, I believe that many people have doubts about how to solve problems caused by UnicodeDecodeError in gethostbyaddr in Python3. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt that "gethostbyaddr causes UnicodeDecodeError in Python3". Next, please follow the editor to study!

Problem description

I am using Python 3.4.1 to build a Django project.

Manage.py runserver throws UnicodeDecodeException.

How to solve?

View the following (trim) retro:

Retro (last recent call):

File C:\ Python34\ lib\ socketserver.py, line 429 _ _ init__ self.server_bind ()

File C:\ Python34\ lib\ site-packages\ django\ core\ servers\ basehttp.py, line 121, in server_bind Super (WSGIServer,self) .server_bind ()

File C:\ Python34\ lib\ wsgiref\ simple_server.py, line 50, server_bind HTTPServer.server_bind (self)

File C:\ Python34\ lib\ http\ server.py, line 135, server_bind self.server_name = socket.getfqdn (host)

File C:\ Python34\ lib\ socket.py, line 460, getfqdn hostname, alias, ipaddrs = gethostbyaddr (name)

UnicodeDecodeError:'utf-8' codec cannot decode 0xcf bytes in position 12 invalid contiguous bytes

For each request, my hostname:

C:\ Users\ AnatoliyVik > hostname AnatoliyVik- hosting solution

Change the hostname to no longer contain Cyrillic characters to resolve the problem.

Thank you @ Lafada for your guidance.

I'm trying to build a Django project with Python 3.4.1. Manage.py runserver raises a UnicodeDecodeException.

How can this be resolved? See the below (trimmed) traceback:

Traceback (most recent call last): 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 121, 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 12: invalid continuation byte

Per request, my hostname:

C:\ Users\ AnatoliyVik > hostnameAnatoliyVik- stories

Changing the hostname to no longer include Cyrillic symbols resolves the problem.

Thanks to @ Lafada for the guidance.

At this point, the study of "how to solve the problem caused by gethostbyaddr in Python3" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report