Python报错socket.gaierror: [Errno 11001] getaddrinfo failed

目录

错误描述

原因

解决


错误描述

在连接使用Hadoop时报错——socket.gaierror: [Errno 11001] getaddrinfo failed

Python报错socket.gaierror: [Errno 11001] getaddrinfo failed 

原因

看到一种回答:

“本地dns解析的host文件,里面的的解析地址被注释了!”

由此猜想,原因可能是:在Hadoop伪分布式部署时,没有将主机ip映射写入本地的host文件中。

解决

修改本地的host文件,添加对应的主机ip映射。(Windows11)

  1. 按Windows键和x键,在弹出的菜单选择Windows Powershell(管理员)
  2. 在打开的页面输入notepad,回车打开记事本页面
  3. 点击文件——打开——选择路径”C:\Windows\System32\drivers\etc\hosts”,将右下角的文件类型选为“所有文件(*.*)”——点击host文件
  4. 添加对应的主机ip映射Python报错socket.gaierror: [Errno 11001] getaddrinfo failed
  5. 保存后修改成功,再次运行发现该错误解决Python报错socket.gaierror: [Errno 11001] getaddrinfo failed

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/b20bcbd01f.html