linux下运行python3爬虫脚本出现错误:Max retries exceeded with url

2023-11-20

错误全称:
ConnectionError: HTTPConnectionPool(host=‘xxx.xx.xxx.xxx’, port=xxxx): Max retries exceeded with url: /api/v1/login/ (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7f7c98a867d0>: Failed to establish a new connection: [Errno 111] Connection refused’,))

公司让爬一个网页的数据,我用python3做好脚本,并且在mac下是可以正常运行的,但是放到linux服务器上就出现了以上的错误,然后就找问题,在网上看了很多博客给的方法很多都是让请求的时候做一些操作,但是我用了都没有解决,最后发现,在linux中没有安装ssl模块,import ssl一直是失败的,所以只要把ssl在安装包中的注释放开,重新make就可以解决这个问题;
解决方法:
进入python安装包中,运行命令vi Modules/Setup,进入后,找到以下内容,并且把注释拿掉在这里插入图片描述
然后重新定位python的位置,然后make 和make install

./configure --prefix=/home/cloud-user/zhangjixuan/python3.6  //这个位置要根据你自己的位置定
make
make install

然后进入python中,能import ssl 就解决问题了~

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

linux下运行python3爬虫脚本出现错误:Max retries exceeded with url 的相关文章

随机推荐