CentOS6安装Python3

1、安装Python3相关包

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make 

2、下载Python3

wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz

3、编译安装

#解压

xz -d Python-3.6.4.tar.xz
tar -xf Python-3.6.4.tar

#进入解压后的目录,依次执行下面命令进行手动编译

./configure --prefix=/usr/local/python36   
make && make install

4、添加环境变量

echo 'export PATH=$PATH:/usr/local/python36/bin' >> ~/.bashrc

5、添加链接

ln -s /usr/local/python36/bin/python3.6 /usr/bin/python

输入python进入Python环境

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注