系统版本:
CentOS Linux release 7.6.1810 (Core)
编译安装Python3.8.4
[root@hankyoon ~]# tar -xvf Python-3.8.4.tgz [root@hankyoon ~]# cd Python-3.8.4/ [root@hankyoon ~]# ./configure --prefix=/usr/local/python3.8 [root@hankyoon ~]# make && make install [root@hankyoon ~]# echo "PATH=/usr/local/mysql/bin:/usr/local/python3.8/bin/:$PATH" >> /etc/profile [root@hankyoon ~]# source /etc/profile
安装requests、pymysql
[root@hankyoon ~]# pip3.8 install requests -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com [root@hankyoon ~]# pip3.8 install pymysql -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
执行MySQL备份脚本:
[root@hankyoon ~]# /usr/local/python3.8/bin/python3.8 /data/db_tools/scripts/db_mysql_bak.py
报错:
Traceback (most recent call last): File "/data/db_tools/scripts/db_mysql_bak.py", line 6, in <module> import requests File "/usr/local/python3.8/lib/python3.8/site-packages/requests/__init__.py", line 43, in <module> import urllib3 File "/usr/local/python3.8/lib/python3.8/site-packages/urllib3/__init__.py", line 42, in <module> raise ImportError( ImportError: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips 26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168
安装openssl-1.0.2r
[root@hankyoon ~]# wget http://www.openssl.org/source/openssl-1.0.2r.tar.gz [root@hankyoon ~]# tar zxvf openssl-1.0.2r.tar.gz [root@hankyoon ~]# ./config --prefix=/opt/openssl1.0.2r --openssldir=/opt/openssl1.0.2r/openssl no-zlib [root@hankyoon ~]# make && make install [root@hankyoon ~]# echo "/opt/openssl1.0.2r/lib" >> /etc/ld.so.conf [root@hankyoon ~]# ldconfig -v [root@hankyoon ~]# cd Python-3.8.4 [root@hankyoon ~]# vim Modules/Setup SSL=/opt/openssl1.0.2r _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto 重新编译Python-3.8.4 [root@hankyoon ~]# cd Python-3.8.4 [root@hankyoon ~]# make && make Install
重新执行MySQL备份脚本,若还报错,将urllib3版本降低
[root@hankyoon ~]# python3.8 -m pip install urllib3==1.26.6
标签:1.0,1.1,2r,local,urllib3,OpenSSL,hankyoon,root,python3.8 From: https://www.cnblogs.com/hankyoon/p/18157787