ubuntu python3.7以上的安装
一去官网等渠道下到安装包;
1,确保系统openssl版本大于OpenSSL 1.0.1,不然就下载:
https://www.openssl.org/source/openssl-1.1.1-pre8.tar.gz
2.编译安装cd openssl-1.1.1-pre8
./config --prefix=/usr/local/openssl no-zlib #不需要zlib
make
make install
3.备份原配置
[root@s2-hadoop-test ~]# mv /usr/bin/openssl /usr/bin/openssl.bak
[root@s2-hadoop-test ~]# mv /usr/include/openssl/ /usr/include/openssl.bak
4.新版配置
#将安装好的openssl 的openssl命令软连到/usr/bin/openssl
[root@s2-hadoop-test ~]# ln -s /usr/local/openssl/include/openssl /usr/include/openssl
#软链到升级后的libssl.so
[root@s2-hadoop-test ~]# ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
#将安装好的openssl命令软连到/usr/bin/openssl
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
5.修改系统配置
#写入openssl库文件的搜索路径
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
#使修改后的/etc/ld.so.conf生效
ldconfig -v
6.查看openssl版本
openssl version
OpenSSL 1.1.1-pre8 (beta) 20 Jun 2018
重新安装python
回到 Python目录,编辑安装文件 Modules/Setup
删除有关 ssl 编译代码的注释,共 4 行。SSL路径改成刚才SSL的安装路径
SSL=/usr/local
/openssl
_ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto
注意:需要指定openssl的安装路径,--with-openssl
./configure --prefix=/usr/local/python37 --with-openssl=/usr/local/openssl
make
make install
Python环境设置-zlib not available
今天在Linux中安Python3的时候,出现了一个错误:zipimport.ZipImportError: can‘t decompress data; zlib not available
网上找了各种办法都无法解决实际问题,记录下解决过程。
错误:
zipimport.ZipImportError: can't decompress data; zlib not available
Makefile:1079: recipe for target 'install' failed
make: *** [install] Error 1
解决办法:安装依赖
1 sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ 2 libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ 3 xz-utils tk-dev
重新 make && make install