编译安装python3.6或python3.8后发现无法导入ssl包,折腾了半天,发现是系统缺乏相关依赖的问题, 很多网友给出的解决方案非常复杂,下面的简单方法亲测可用!
1.在编译前安装相关依赖:
Ubundu/Debian
sudo apt-get install openssl -y
sudo apt-get install libssl-dev -y
RedHat/Centos
sudo yum install openssl -y
sudo yum install openssl-devel -y
2.然后在执行make安装命令
sudo ./configure --prefix=/user/local/python36/
sudo make
sudo make install
3.安装成功后测试如下:
Python 3.6.9 (default, Apr 25 2021, 16:56:56)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
安装成功!