ubuntu安装python3.8-ssl

  1. 下载 openssl
    https://www.openssl.org/source/old/1.1.1/openssl-1.1.1d.tar.gz
    注意:python3.8 最好下载高版本 openssl
  2. 编译 openssl
1
2
3
4
5
6
tar zxvf openssl-1.1.1d.tar.gz openssl-1.1.1d
cd openssl-1.1.1d
sudo ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
sudo make
sudo make test
sudo make install
  1. 将编译后 openssl 动态库,加入搜索路径
1
2
3
4
5
6
7
sudo mkdir lib64
sudo ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
sudo ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
sudo su
echo "/usr/lib64" >> /etc/ld.so.conf.d/lib64.conf
// 查看是否成功
ldconfig -v
  1. 下载 python3.8.5
    https://www.python.org/downloads/source/
  2. 解压 python
1
2
3
tar zxvf python3.8.5.tar.gz python3.8.5
cd python3.8.5
sudo apt-get install libffi-dev
  1. 修改配置
    vi modules/Setup
    放开如下注释:
1
2
3
4
SSL=/usr/local/openssl
\_ssl \_ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
  1. 编译 python
1
2
3
4
sudo ./configure --prefix=/usr/local/python
sudo make
sudo make install

  1. 加入动态管理 python
1
2
sudo update-alternatives --install /usr/bin/python python /usr/local/python/python3.8.5/bin/python3.8 3
sudo update-alternatives --config python
发布于

2022-07-06

更新于

2023-08-18

许可协议

评论