python -v 查看当前系统默认python版本
which python 查找默认python的安装路径 默认在/usr/bin/python下
yum install -y gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel 或
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make 安装相关包
wget https://www.python.org/ftp/python/3.5.2/Python-2.7.13.tar.xz 下载python2.7版本
tar xf Python-2.7.13.tar.xz -C /usr/local/src/ 解压安装包到指定目录(yum -y install xz #若失败,重建yum缓存.yum clean all ,yum makecache)
cd /usr/local/src/Python-2.7.13 进入安装目录
./configure --prefix=/usr/local/python27 配置python安装路径
make && make install 安装
pip install virtualenv 安装虚拟环境
virtualenv -p /usr/local/python27 TestEnv # 创建虚拟环境,名称为TestEnv -p参数指定Python解释器程序路径 这将会使用 /usr/bin/python2.7
进入TestEnv/bin目录,执行source activate命令即可激活
virtualenv /root/myvirenv/py27env --python=/usr/local/python27/bin/python2.7 指定虚拟环境所有python的路径
原文地址:https://www.cnblogs.com/zz27zz/p/8989831.html