CentOS7 安装Python3.9以上版本时。编译报错,原因是openssl版本低

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安装情况  

[root@localhost ~]# 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官方下载最新的代码包,因为源站下载速度过慢,所以我使⽤了腾讯云的镜像

#从官网下载

下载前先

yum remove 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=/opt/openssl --prefix=/opt/openssl
make && make install

4.配置

echo "/opt/openssl/lib/" >> /etc/ld.so.conf

ln -sf /opt/openssl/bin/openssl /usr/bin/openssl #需要默认在/usr/bin/下创建openssl的软连接

ldconfig -v

openssl version

5.测试

[oracle@localhost ~]$ 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
>>> 

  成功!

 


 

posted @ 2023-02-23 16:21  Magiclala  阅读(433)  评论(0编辑  收藏  举报