一、背景
春儿小说网 https://www.1763.info
公司一小伙子反馈在内网机器上通过代理,还是安装不了bs4;于是乎,作为菜鸡的我开始排查。一直认为是网络和代理问题,所以关注点一直放在网络和安装包上;在网上搜索到,主要是以下问题:
1)更新apt-get update,再安装;
2)pip的代理有问题,一直再排查代理
3)是安装bs4,不是beautifulsoup4
而自己一直在纠结apt-get源的升级,怎么升都升不上;换了各种源/etc/apt/source.list,也没用。最后觉得可能自己对bs4这个东西不熟悉,还是好好的来了解学习一下,再来解决这个问题;于是乎找到了它的官网。em....;好家伙,一打开就看到了在最新版的Ubuntu下如何安装bs4。整个时间直到解决这个问题前前后后加起来用了一天。
二、总结
1)有问题先查官网
2)别人的答案不一定适用于你的问题,比如我的版本是Ubuntu20,而网上的答案都是针对与Ubuntu18的
3)别人给你反馈问题的时候,别人给你的只是他对这个问题的猜想,你得要他提供事实,然后根据自己的判断解决问题;比如这里别人跟我反馈是代理和网络的问题,我就一直往这个方向上去解决,结果完全不是。
三、报错信息
root@xxxx:~# pip install bs4 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. WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 403 Forbidden',))': /simple/bs4/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 403 Forbidden',))': /simple/bs4/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 403 Forbidden',))': /simple/bs4/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 403 Forbidden',))': /simple/bs4/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', error('Tunnel connection failed: 403 Forbidden',))': /simple/bs4/ ERROR: Could not find a version that satisfies the requirement bs4 (from versions: none) ERROR: No matching distribution found for bs4
四、正确的方式
#Python2安装 apt-get install -y python-bs4 #Python3安装 apt-get install -y python3-bs4
五、测试
1)输入一段文档