centos 安裝配置python虛擬環境、pip
centos 安裝配置python虛擬環境、pip
1.安裝pip包安裝工具
# 系統默認源沒有pip安裝包
[root@localhost 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源
[root@localhost python]# yum -y install epel-release
# 再次安裝
[root@localhost python]# yum install python-pip
.....
Installed:
python2-pip.noarch 0:8.1.2-6.el7
Complete!
# 安裝成功
2.安裝virtualenv
2.1 使用pip安裝virtualenv
[root@localhost python]# pip install virtualenv
如果提示You should consider upgrading via the ‘pip install --upgrade pip‘ command.
就執行pip install --upgrade pip更新後再安裝即可
2.2 使用yum安裝virtualenv
[root@localhost python]# yum install python-virtualenv
3.配置python虛擬環境
# 創建名為env1的虛擬環境
[root@localhost python]# virtualenv env1
# 進入虛擬環境
[root@localhost python]# source env1/bin/activate
(env1) [root@localhost python]#
# 退出虛擬環境
(env1) [root@localhost python]# deactivate
[root@localhost python]#
centos 安裝配置python虛擬環境、pip