pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=’pypi.org’, port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”)) – skipping

内容纲要

一、问题

执行pip install报错 或 pip list提示SSL Module not available

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

二、原因

1、编译Python的时候,系统缺少一些依赖
2、pip版本太高了,当 pip 版本高于 20.3 后才会出现此错误

三、解决方案

1、【推荐】因此我们可以手动将 pip 版本降级至 20.2.4 或者 20.3b1 等较低版本即可

python -m pip install pip==20.2.4 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
python -m pip install pip==20.2.4 -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com

2、从源码编译python前,执行以下命令后,再进行Python源码编译构建。

3.1 编译环境依赖安装

sudo apt-get update
sudo apt-get install libffi-dev
sudo apt install sqlite*
sudo apt-get install libbz2-dev
ll /usr/include/openssl
sudo apt-get install -y openssl libssl-dev
sudo apt-get install build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev

3.2 从源码编译Python

# 编译python增加 --with-ssl
./configure --prefix=/root/software/python39/ --enable-shared --enable-optimizations --with-ssl
sudo make
sudo make install
/root/software/python39/bin/pip3 list
/root/software/python39/bin/python3.9 -m pip install --upgrade pip
/root/software/paddleOCR/paddleOCR/venv-cpu/bin/python3 -m pip install --upgrade pip

四、参考资料

Leave a Comment

您的电子邮箱地址不会被公开。 必填项已用*标注

close
arrow_upward