【Python包】pip安装teradatasql时提示没有TLS/SSL模块

 1.问题描述

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

2.问题原因

 当前行系统没有openssl或者版本比较低,一般python3.7需要的openssl的版本为1.0.2或者1.1.x。需要对openssl进行升级,并重新编译python3.7.0。yum 安装的openssl 版本都比较低。

3.解决方法

3.1查看是否安装及版本

#查看是否安装
rpm -aq|grep openssl
#查看版本号
openssl version 或者 openssl version -a

3.2升级openssl

(1)openssl下载地址:openssl-1.1.1a.tar.gz

#创建安装目录
mkdir -p usr/local/openssl
#解压
tar -zxvf openssl-1.1.1a.tar.gz
cd openssl-1.1.1a
# 编译安装
./config --prefix=/usr/local/openssl no-zlib #不需要zlib
make
make install

如果运行./configur编译的时候,提示Perl的版本太低,无法编译。参考如下链接解决:OpenSSL升级提示perl版本较低(安装Perl)

(2)替换旧版本配置

# 备份原低版本配置
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl/ /usr/include/openssl.bak
# 新版配置
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
# 修改系统配置
## 写入openssl库文件的搜索路径
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
## 使修改后的/etc/ld.so.conf生效 
ldconfig -v

(3)查看openssl版本

openssl version

错误提示: /usr/local/openssl/bin/openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

#假如你的libssl.so.1.1 文件在/usr/local/openssl/lib/下面,可以这样做
ln
-s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1 ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

3.3 重新安装python

cd Python-3.6.8
make clean
make distclean
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl make make install

 3.4重新安装teradatasql

pip install teradatasql    #安装
pip install --no-cache-dir -U teradatasql  #升级

参考文档:

解决pip is configured with locations that require TLS/SSL问题

python pip 出现locations that require TLS/SSL异常处理方法

如何查看openssl版本号

原文地址:https://www.cnblogs.com/badboy200800/p/11207469.html