安装virtualenv,可以虚拟多个python版本的环境
1、安装epel源
[[email protected] ~]# yum install epel-release -y
2、安装python-virtualenv
[[email protected] ~]# yum install python-virtualenv -y
3、创建virtualenv环境
[[email protected] ~]# mkdir ~/.virtualenv [[email protected] .virtualenv]# virtualenv --python=/home/python27/bin/python pyweb Running virtualenv with interpreter /home/python27/bin/python New python executable in pyweb/bin/python Installing Setuptools..............................................................................................................................................................................................................................done. Installing Pip.....................................................................................................................................................................................................................................................................................................................................done. [[email protected] .virtualenv]# source ./pyweb/bin/activate (pyweb)[[email protected] .virtualenv]# (pyweb)[[email protected] .virtualenv]# #出现(pyweb)说明你已经进入虚拟环境了 #进入虚拟环境 #source ~/.virtualenv/pyweb/activate # #退出虚拟环境 (pyweb)[[email protected] .virtualenv]# deactivate [[email protected] .virtualenv]# (pyweb)[[email protected] pyweb]# python --version Python 2.7.11 (pyweb)[[email protected] pyweb]# (pyweb)[[email protected] pyweb]# deactivate [[email protected] .virtualenv]# virtualenv pyweb1 New python executable in pyweb1/bin/python Installing Setuptools..............................................................................................................................................................................................................................done. Installing Pip.....................................................................................................................................................................................................................................................................................................................................done. [[email protected] .virtualenv]# [[email protected] .virtualenv]# source pyweb1/bin/activate (pyweb1)[[email protected] .virtualenv]# python --version Python 2.6.6 (pyweb1)[[email protected] .virtualenv]#
#完成了!
时间: 2024-10-10 15:16:40