Linux环境下安装python3.6

一般Linux自带的python2环境不满足我们的开发 ,如果强行覆盖安装,会出现yum不能使用等各种异常,所以安装一个3.6

一、安装依赖包,如果依赖包存在,则跳过一个步:

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

二、下载python包
https://www.python.org/downloads/

[root@dd ~]# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz

三、创建安装目录,将刚下载的安装包移动到安装目录

[root@dd ~]# mkdir /opt/python3.6
[root@dd ~]# mv Python-3.6.1.tgz /opt/python3.6/

四、解压并安装

[root@dd ~]# cd /opt/python3.6
[root@dd python3.6]# tar xf Python-3.6.1.tgz
[root@dd python3.6]# cd Python-3.6.1/
[root@dd Python-3.6.1]# ./configure --prefix=/opt/python3.6/python3
[root@dd Python-3.6.1]# make && make install

五、创建软链接

[root@dd Python-3.6.1]# ln -s /opt/python3.6/python3/bin/python3.6 /usr/bin/python3.6
[root@dd Python-3.6.1]# ln -s /opt/python3.6/python3/bin/pip3.6 /usr/bin/pip3.6

六、验证

[root@dd ~]# python3.6 -V
Python 3.6.1
[root@dd ~]# pip3.6 -V
pip 9.0.1 from /opt/python3.6/python3/lib/python3.6/site-packages (python 3.6)
Logo

更多推荐