一、CentOS6.5 安裝Python 的依賴包python
yum groupinstall "Development tools" yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devellinux
二、下載Python3.5的源碼包並編譯git
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.2.tgz tar xf Python-3.5.0.tgz cd Python-3.5.2 ./configure --prefix=/usr/local --enable-shared make make install ln –s /usr/local/bin/python3 /usr/bin/python3github
三、在運行Python以前須要配置庫:sql
echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf ldconfig工具
四、運行演示:post
python3 --version Python 3.5.0.net
五、刪除編譯Python時所須要的庫sqlite
yum groupremove "Development tools" --remove-leaveas yum remove zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel --remove-leavesblog
六、設置別名方便使用
alias py=python3
七、CentOS 安裝easy_install、pip的方法
CentOS 安裝easy_install的方法:
wget -q http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py 八、CentOS安裝python包管理安裝工具pip的方法以下:
wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
注意:wget獲取https的時候要加上:--no-check-certificate
tar zvxf 1.5.5 #解壓文件 cd pip-1.5.5/ python3 setup.py install
OK,這樣就安裝好pip了,
下面來安裝 requests吧。
pip3 install requests