Blogger Information
Blog 41
fans 0
comment 1
visits 40362
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Linux下搭建virtualenv、virtualenvwrapper虚拟环境
yeyiluLAMP
Original
1035 people have browsed it

Linux下搭建virtualenv和virtualenv包管理工具virtualenvwrapper

Ubuntu:

Ubuntu下pip的安装与升级

sudo apt-get install python-pip
sudo pip install --upgrade pip
sudo apt-get install python3-pip
sudo pip3 install --upgrade pip


python安装虚拟环境virtualenv

sudo apt-get install python-virtualenv

创建虚拟环境virtualenv 项目名称 py2 (默认情况下创建Python2版本)

virtualenv py2

进入项目py2目录

cd py2/bin

启动virtualenv

source activate

创建Python3版本虚拟环境 项目名称 py3

virtualenv -p /usr/bin/python3 py3

进入项目py3目录

cd py3/bin

启动virtualenv

source activate


安装virtualenvwrapper

594a79a9000106d805450330.png

在当前家目录下创建一个专门存放虚拟环境的文件夹

mkdir .virtualenvs

vim ~/.bashrc   在最后两行加上以下命令

VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/python3/bin/virtualenv
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/python3/bin/virtualenvwrapper.sh

重新加载.bashrc文件

source  ~/.bashrc


workon 显示当前已经创建的虚拟环境的项目

594a7a630001ccd206770121.png

新建虚拟环境py2test (默认是创建Python2版本的虚拟环境)

mkvirtualenv py2test

进入虚拟环境

1.png

退出当前的虚拟环境

2.png

创建Python3版本虚拟环境 项目名称 py3test

5.png

6.png

退出当前的虚拟环境

7.png


CentOS:

安装virtualenvwrapper

yum install python-setuptools python-devel 
pip install virtualenvwrapper

其它操作与Ubuntu一致


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!