centos7 python3安装 虚拟环境创建

1、安装相关包,用于下载编译python3

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

2、解压python3,安装包 并编译

tar -zvxf Python-3.6.4.tgz
mv Python-3.6.4 python-3.6.4 #修改文件名
cd python-3.6.4

# 手动编译
./configure prefix=/usr/local/python3
make && make all

#添加python3的软链接
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
#测试是否安装成功了
python3 -V

3、创建虚拟环境

python3 -m venv ../venv/python  # 创建名为python虚拟环境 版本python3

# 进入虚拟环境
source ../venv/python/bin/activate 
# 退出虚拟环境
deactivate

你可能感兴趣的:(python)