Centos上面默認的Python版本是2.6,本文介紹如何安裝3.4版本。
0.下載前准備
需要安裝以下庫,不然會有問題。
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
1. 下載Python3.4源碼
# wget http://mirrors.sohu.com/python/3.4.1/Python-3.4.1.tar.xz
2. 解壓縮並安裝
# xz -d Python-3.4.1.tar.xz
# tar xf Python-3.4.1.tar -C /usr/local/src/
# cd /usr/local/src/Python-3.4.1/
# ./configure --prefix=/usr/local/python34
# make -j8 && make install
3. 安裝的目錄
默認情況下,python會安裝在
/usr/local/python34
4. 安裝PyMySQL
PyMySQL是python的mysql庫,安裝方法如下:
/usr/local/python34/bin/pip3 install PyMySQL