linux安装python3.x版本
- ① 安装依赖环境
- ② 下载python版本包
- ③ 安装python
- ④ 建立软链接
- ⑤ 加入path
- ⑥ 验证
官网版本地址:https://www.python.org/ftp/python/
① 安装依赖环境
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.9.0/Python-3.9.0.tgz
③ 安装python
mkdir -p /usr/local/python3.9.0
tar -zxvf Python-3.9.0.tgz
cd Python-3.6.1
./configure --prefix=/usr/local/python3.9.0
make && make install
④ 建立软链接
ln -s /usr/local/python3.9.0/bin/python3 /usr/bin/python3
ln -s /usr/local/python3.9.0/bin/pip3 /usr/bin/pip3
⑤ 加入path
vim ~/.bash_profile
# .bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/bin:/usr/local/python3.9.0/bin
export PATH
source ~/.bash_profile