错误发生介绍:
阿里云服务器安装库文件总是提醒无法连接镜像地址:Could not fetch URL https://mirrors.aliyun.com/pypi/simple/lxml/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘mirrors.aliyun.com’, port=443)
以及
Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”
原代码运行情况:
#安装代码
[root@Z /]# sudo pip3 install lxml
#警告;无法连接
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Looking in indexes: https://mirrors.aliyun.com/pypi/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /pypi/simple/lxml/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /pypi/simple/lxml/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /pypi/simple/lxml/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /pypi/simple/lxml/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /pypi/simple/lxml/
#错误提示
Could not fetch URL https://mirrors.aliyun.com/pypi/simple/lxml/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='mirrors.aliyun.com', port=443): Max retries exceeded with url: /pypi/simple/lxml/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
ERROR: Could not find a version that satisfies the requirement lxml (from versions: none)
ERROR: No matching distribution found for lxml
在使用pip 或者pip3 install 库或者* 爬虫爬取HTTPs*时
有时SSL报错
查看最根源的错误是**“Can’t connect to HTTPS URL because the SSL module is not available.”**
**可以直接将相应镜像地址设置为信任 **
pip3 install beautifulsoup4 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
也可以将阿里云镜像地址设置为信任,也可以换用国内其他镜像源
完美解决问题:
[root@iZv8e15lj6mauuZ /]# pip3 install lxml -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
Looking in indexes: http://pypi.douban.com/simple
Collecting lxml
Downloading http://pypi.doubanio.com/packages/bd/78/56a7c88a57d0d14945472535d0df9fb4bbad7d34ede658ec7961635c790e/lxml-4.6.2-cp36-cp36m-manylinux1_x86_64.whl (5.5 MB)
|████████████████████████████████| 5.5 MB 60.0 MB/s
Installing collected packages: lxml
ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.
We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.
docx 0.2.4 requires Pillow>=2.0, which is not installed.
Successfully installed lxml-4.6.2