python2和3.6.5兼容安装
1、准备编译环境(环境如果不对的话,可能遇到各种问题,比如wget无法下载https链接的文件)
yum install gcc-c++ python-devel.x86_64 cyrus-sasl-devel.x86_64
yum groupinstall 'Development Tools'
yum -y install libffi-devel
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel
2、下载 Python3.6.5代码包
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
3、编译
tar Jxvf Python-3.6.5.tar.xz
cd Python-3.6.5
./configure --prefix=/usr/local/python3
make && make install
4、设置环境变量
echo 'export PATH=$PATH:/usr/local/python3/bin' >> ~/.bashrc
5、设置目录
ln -sv /usr/local/python3/bin/python3.6 /usr/bin/python3
这样做的目的是在系统任意目录敲入python3调用的是python3.6的命令
部分转自从http://www.jb51.net/article/115370.htm
网友评论