1、安装依赖包
yum -y install wget zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel gcc gcc++
2、下载python包、解压、编译安装
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz tar -xzvf ./Python-3.6.0.tgz -C /usr/local/src/ cd /usr/local/src/Python-3.6.0/ ./configure --prefix=/usr/local/python make make install
3、更改环境变量并使其生效、验证
vim ~/.bash_profile PATH=$PATH:$HOME/bin # 改为: PATH=$PATH:$HOME/bin:/usr/local/python/bin source ~/.bash_profile python3 -V
4、设置默认python版本
mv /usr/bin/python /usr/bin/python2.6 ln -s /usr/local/python/bin/python3.6 /usr/bin/python
5.核对Python版本
python -V Python 3.6.0 python2.6 -V Python 2.6.6
6、更改yum程序,yum程序要用到python 2.X
vi /usr/bin/yum 将 #!/usr/bin/python 改成 #!/usr/bin/python2.6
7、pip安装模块(机器时间要准确)
pip3 install requests 这个是安装解压rar包的模块 pip3 install unrar pip3 install rarfile