1.安装pip包安装工具
# 系统默认源没有pip安装包
[[email protected] python]# yum install python-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: repos.dfw.quadranet.com
* extras: sjc.edge.kernel.org
* updates: mirror.hmc.edu
No package python-pip available.
Error: Nothing to do
# 安装epel源
[[email protected] python]# yum -y install epel-release
# 再次安装
[[email protected] python]# yum install python-pip
.....
Installed:
python2-pip.noarch 0:8.1.2-6.el7
Complete!
# 安装成功
2.安装virtualenv
2.1 使用pip安装virtualenv
[[email protected] python]# pip install virtualenv
如果提示You should consider upgrading via the ‘pip install --upgrade pip‘ command.
就执行pip install --upgrade pip更新后再安装即可
2.2 使用yum安装virtualenv
[[email protected] python]# yum install python-virtualenv
3.配置python虚拟环境
# 创建名为env1的虚拟环境
[[email protected] python]# virtualenv env1
# 进入虚拟环境
[[email protected] python]# source env1/bin/activate
(env1) [[email protected] python]#
# 退出虚拟环境
(env1) [[email protected] python]# deactivate
[[email protected] python]#
原文地址:https://www.cnblogs.com/change06/p/9800152.html