python在Linux执行时报错:
socket.gaierror: [Errno -2] Name or service not known requests.exceptions.ConnectionError: HTTPConnectionPool(host='xxxx(域名)', port=80): Max retries exceeded with url: /.../.. (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fe417c772e0>: Failed to establish a new connection: [Errno -2] Name or service not known'))
产生原因:由于域名没有在配置文件中指定,因此无法找到对应的IP。通过在hosts文件添加ip 域名信息,即可解决。
执行命令vi /etc/hosts,加入
10.10.10.10 xxxxxxxx(域名)