centos安装python3.6.3

centos安装python3.6.3

先来进行扫清安装问题,升级相关软件

    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 wget

创建文件夹并安装等操作

wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
mkdir -p /usr/local/python3
tar -zxvf Python-3.6.3.tgz
cd Python-3.6.3/
./configure --prefix=/usr/local/python3 && make && make install

Python3的软链接,并将/usr/local/python3/bin加入bash_profile

ln -s /usr/local/python3/bin/python3 /usr/bin/python3
vim ~/.bash_profile

进入到脚本文件,将python环境加入到path中,并进行导出

# .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

PATH=$PATH:$HOME/bin

export PATH

编译文件,查看是否安装成功

source ~/.bash_profile

你可能感兴趣的:(操作系统)