我在3天后解决了这个问题,只是因为this blog.使用了python 3.7.4openssl 1.1.0centos 6。
总结如下:
首先,一些先决条件:sudo apt-get install build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
如果使用centos linux,请使用yum而不是apt-get。
安装ssl 1.0.2或更高版本。cd /usr/src
curl https://www.openssl.org/source/openssl-1.0.2o.tar.gz | tar xz
cd openssl-1.0.2o
./config shared --prefix=/usr/local/
sudo make
sudo make install
我们需要将/usr/src/openssl-1.0.2o传递到Python配置脚本中。mkdir lib
cp ./*.{so,so.1.0.0,a,pc} ./lib
现在继续安装Python:cd /usr/src
sudo wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
sudo tar xzf Python-3.7.0.tgz
cd Python-3.7.0
./configure --with-openssl=/usr/src/openssl-1.0.2o --enable-optimizations
sudo make
sudo make altinstall
要测试它,请运行python3.7并输入:import ssl
ssl.OPENSSL_VERSION
希望有帮助!