本机环境
CentOS 6.5
*自带有python2,不要动
安装python3.6
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.6
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
3.安装python3
创建目录(路径可自选):
mkdir -p /usr/local/python3
解压安装包:
tar -zxvf Python-3.6.1.tgz
4.进入解压后的目录,编译安装
cd Python-3.6.1
./configure --prefix=/usr/local/python3
make && make install
5.建立python3的软链
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
6.并将/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
按ESC,输入:wq后回车退出。
执行行下面的命令,让上一步的修改生效:
source ~/.bash_profile
检查Python3是否可用:
python3 -V
---- Python 3.6.1