本文轉(zhuǎn)載自博客園ESHLkangi:https://www.cnblogs.com/ESHLkangi/p/8545979.html
1律歼、安裝依賴環(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
2睛约、下載Python3.6
新建個/usr/download 文件夾
mkdir /usr/download
在download文件夾下下載安裝包(/usr/download )
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
解壓文件
tar -xvf Python-3.6.4.tgz
3眉菱、安裝Python3
創(chuàng)建安裝文件的路徑
mkdir /usr/local/python3
4、編譯(在解壓的文件夾下 /usr/download/python3.6.4)
./configure --prefix=/usr/local/python3
5、安裝(在解壓的文件夾下 /usr/download/python3.6.4)
make
make install
6鱼炒、創(chuàng)建新版本的軟鏈接
修改舊版本
mv /usr/bin/python /usr/bin/python_bak
創(chuàng)建新的軟連接
ln -s /usr/local/python3/bin/python3 /usr/bin/python
檢查python的版本
python -V
7泥彤、配置成功后欲芹,pip3用不了,需要進一步配置
將/usr/local/python3/bin加入PATH
vim ~/.bash_profile
修改后如下:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
保存退出后吟吝,執(zhí)行以下命令菱父,讓上一步修改成功
source ~/.bash_profile
完成!