現(xiàn)在很多python程序都是在python3環(huán)境下運(yùn)行蒋失,但是linux下自帶的環(huán)境一般都是python2正什,下面簡(jiǎn)單介紹環(huán)境安裝過(guò)程(原python2不可卸載丑慎,部分程序依賴此運(yùn)行:如yum)
安裝依賴環(huán)境
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel
sqlite-devel readline-devel tk-devel gdbm-devel db4-devel
libpcap-devel xz-devel
下載python包
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
python安裝
1. 創(chuàng)建python3安裝路徑
mkdir -p /usr/local/python3
2. 解壓包文件
tar -zxvf Python-3.6.1.tgz
3. 進(jìn)入解壓后的目錄移剪,編譯安裝
cd Python-3.6.1
./configure --prefix=/usr/local/python3
4. 執(zhí)行 make && make install
添加軟連接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
添加環(huán)境變量
export PATH=$PATH:/usr/local/python3/bin