安装openssl-1.1.1

1.前因

python 导入clickhouse_driver需要import ssl和_ssl,报错  

File "/home/oracle/python3/lib/python3.7/site-packages/clickhouse_driver-0.1.2-py3.7-linux-x86_64.egg/clickhouse_driver/__init__.py", line 2, in <module>
    from .client import Client
  File "/home/oracle/python3/lib/python3.7/site-packages/clickhouse_driver-0.1.2-py3.7-linux-x86_64.egg/clickhouse_driver/client.py", line 1, in <module>
    import ssl
  File "/home/oracle/python3/lib/python3.7/ssl.py", line 98, in <module>
    import _ssl             # if we can‘t import it, let the error propagate
ImportError: libssl.so.1.1: cannot open shared object file: No such file or director

查看openssl安装情况  

[ ~]# rpm -aq|grep openssl
openssl-1.0.1e-58.el6_10.x86_64
openssl-devel-1.0.1e-58.el6_10.x86_64

版本是1.0.1e,不符合需求

2.下载openssl

从 openssl官网下载最新的代码包,因为源站下载速度过慢,所以我使用了腾讯云的镜像

#从官网下载
# wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz

#腾讯云提供的镜像
wget https://mirrors.cloud.tencent.com/openssl/source/openssl-1.1.1g.tar.gz

3. 编译 openssl

tar -xvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl
make && make install

4.配置

echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf
ldconfig

5.测试

[ ~]$ python3
Python 3.7.2rc1 (default, Nov  1 2019, 08:59:21) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>

成功!