centos6下编译安装python3.7

在centos6中编译python3.7,网上一大堆教程要么是centos7的,要么就是没有验证过乱抄的,这里整理一份使用的教程

直接上安装过程吧,软件包我都挡在/usr/local/src下

下载软件包

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz

如果是centos6的话你需要先更新openssl,不更新编译后的python会提示你未激活ssl,而且这个在线更新不行,你需要编译

openssl目前最新版是https://www.openssl.org/source/openssl-1.0.2p.tar.gz,编译教程看这个https://sulao.cn/post/146.html

然教程做完了,我们开始编译python3.7

yum install libffi-devel -y #依赖包
tar -zxvf Python-3.7.0.tgz
cd Python-3.7.0
mkdir -p /usr/local/python3
#If you want a release build with all stable optimizations active (PGO, etc),please run ./configure --enable-optimizations
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl --enable-optimizations
make && make install

编译好以后我们需要做一个软连接到/usr/bin目录下

ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3

接下来我们就直接python3进入python3.7的交互界面了。

我们导入ssl模块试试,看看有没有问题

menu.saveimg.savepath20181106175853.jpg

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://sulao.cn/post/572.html

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。