安装python3.x
1.安装依赖环境
1 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.x
1 https://www.python.org/downloads/ 2 wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
3.安装python
1 创建目录 2 mkdir -p /usr/local/python3 3 解压缩 4 tar -zxvf Python-3.6.1.tgz 5 进入解压缩目录,编译安装 6 cd Python-3.6.1 7 ./configure --prefix=/usr/local/python3 8 make && make install
1 创建软连接 2 ln -s /usr/local/python3/bin/python3 /usr/bin/python3
4.将python加入环境变量
1 # vim ~/.bash_profile 2 # .bash_profile 3 # Get the aliases and functions 4 if [ -f ~/.bashrc ]; then 5 . ~/.bashrc 6 fi 7 # User specific environment and startup programs 8 PATH=$PATH:$HOME/bin:/usr/local/python3/bin 9 export PATH
执行命令生效
source ~/.bash_profile
5.查看python和pip版本
# python3 -V Python 3.6.1 # pip3 -V pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)