ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

python报错:Failed to establish a new connection: [Errno -2] Name or service not known

2021-10-08 10:06:26  阅读:716  来源: 互联网

标签:Name service py site 报错 usr pip requests packages


详细报错内容:

Traceback (most recent call last):
File "/usr/local/python3/lib/python3.7/site-packages/ddt.py", line 192, in wrapper
return func(self, *args, **kwargs)
File "/usr/hxy/auto-test/interface/test_start.py", line 49, in test
result = RequestsHandle().httpRequest(method, reparam.uri, data=reparam.data, headers=reparam.headers)
File "/usr/hxy/auto-test/common/request_handle.py", line 32, in httpRequest
headers=headers, verify=False, proxies=proxies)
File "/usr/local/python3/lib/python3.7/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/python3/lib/python3.7/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/python3/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='sync-test.helianhealth.com', port=443): Max retries exceeded with url: /sync-channel/channel/admin/hsp/template/isOnline (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fd369b643c8>: Failed to establish a new connection: [Errno -2] Name or service not known'))

在我本地是不会出现该报错,部署在linux服务器运行项目就会出现该错误。

因为除了我在运用该台服务器还有别的技术人员在使用,requests版本落后导致的。

解决方法:更新requests 命令: pip install -U requests

如果出现下面报错:

ERROR: Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

使用distutils安装了某个包,你需要通过distutils来卸载这个包。不幸的是distutils不包含卸载命令,所以 "uninstall using distutils"就意味着你要手动移除这个包。

cd /usr/lib/python2.7/site-packages/
mkdir /opt/pylib_backup/
mv requests* /opt/pylib_backup/

pip list 看到 requests包被卸载了

[root@bareos_server site-packages]# pip list |grep request
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
[root@bareos_server site-packages]# 


 

标签:Name,service,py,site,报错,usr,pip,requests,packages
来源: https://blog.csdn.net/u010428264/article/details/120645947

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有