1,centos7 源码安装python3

因centos7默认自带python版本为2.7.5,使用python3时,需要配置venv:

安装所需要的包:

# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

编译安装 python3.5.2.tgz <自动安装pip3>

./configure

make 

make install

创建虚拟环境:

/usr/local/bin/pyvenv-3.5   /py3vevn

激活虚拟环境:

source  /py3env/bin/activate

如果要退出python3虚拟环境,输入命令

deactivate

2,centos7 yum 安装python3

# yum install python36 -y              安装

# rpm -ql python36                查看
# /usr/bin/pyvenv-3.6 /py36vevn            创建虚拟化环境
# source /py36vevn/bin/activate            激活
# deactivate                   退出