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
原文地址:http://blog.51cto.com/net881004/2130362
时间: 2024-10-06 20:34:50