Centos6 安装python3.6
1.安装依赖包
yum install bzip2-devel db4-devel expat-devel gcc gdbm-devel libffi-devel libpcap-devel ncurses-devel openssl-devel patch python-devel readline-devel sqlite-devel tk-devel xz-devel zlib-devel -y
2.下载python3.6安装包:
wget --no-check-certificate https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
3.解压到当前目录:
tar -zxvf Python-3.6.0.tgz
4.打开文件夹
cd Python-3.6.0
5.配置并编译安装
./configure --prefix=安装python的路径 --enable-shared
make & make install
6.重新建立连接
mv /usr/local/bin/python /usr/local/bin/python_bak
ln -s /usr/local/python3.6/bin/python3 /usr/bin/python3
7.完成后,会发现yum用不了,因为yum是使用的python2.6的版本,所以还需要修改一下,修改第一行
# vim /usr/bin/yum
把!/usr/bin/python修改为!/usr/bin/python2.6
重新运行yum就可以使用了
8.此时运行python3命令的话会报错,缺少.so文件,我们需要进行如下操作:
cp -R /usr/local/python3/lib/* /usr/lib64/
9.安装所需要的包
10.测试python是否安装完成,在命令行键入
# python