socket.gaierror: [Errno 8] nodename nor servname provided, or not known

 

原因:hostname 没有写在/etc/hosts里

干脆利索,解决方案:

  1.需要将hostname写到hosts文件里,怎么获取hostname

python   # 进入python环境
>>>import socket
>>>socket.gethostname()
>>>>exit()

  2.修改hosts文件

vim /etc/hosts

127.0.0.1    hostname   # 将获取到的hostname写进来

  3.Mac系统修改hosts文件有权限限制,本人已成功解决,参考链接

https://jingyan.baidu.com/article/f3ad7d0f55154309c3345bdd.html

 

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2021-12-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-09-18
  • 2021-07-11
  • 2022-01-10
相关资源
相似解决方案