1. Introduction

Virtualenvwrapper is a set of extensions to Ian Bicking’s virtualenv tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.

2. Installation

$ sudo pip install virtualenvwrapper

$ vim ~/.bashrc
    # add three lines
    export WORKON_HOME=$HOME/.virtualenvs
    export PROJECT_HOME=$HOME/Projects/Python
    source /usr/local/bin/virtualenvwrapper.sh
$ source ~/.bashrc

3. Command

3.1 mkvirtualenv

Create a new environment, in the WORKON_HOME.

mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] ENVNAME
# -a: associate an existing project directory with the new environment.
# -i: install one or more packages after the environment is created.
# -r: specify a text file listing packages to be installed.

3.2 mktmpenv

Create a new temporary virtualenv in the WORKON_HOME directory. A unique virtualenv name is generated.

mktmpenv [(-c|--cd)|(-n|--no-cd)] [VIRTUALENV_OPTIONS]

If -c or --cd is specified the working directory is changed to the virtualenv directory during the post-activate phase, regardless of the value of VIRTUALENVWRAPPER_WORKON_CD.

If -n or --no-cd is specified the working directory is not changed to the virtualenv directory during the post-activate phase, regardless of the value of VIRTUALENVWRAPPER_WORKON_CD.

3.3 lsvirtualenv

List all of the environments.

lsvirtualenv [-b] [-l] [-h]
# -b: Brief mode, disables verbose output.
# -l: Long mode, enables verbose output. Default.
# -h: Print the help for lsvirtualenv.

3.4 showvirtualenv

Show the details for a single virtualenv.

showvirtualenv [env]

3.5 rmvirtualenv

Remove an environment, in the WORKON_HOME.

rmvirtualenv ENVNAME

3.6 cpvirtualenv

Duplicate an existing virtualenv environment. The source can be an environment managed by virtualenvwrapper or an external environment created elsewhere.

cpvirtualenv ENVNAME [TARGETENVNAME]

3.7 allvirtualenv

Run a command in all virtualenvs under WORKON_HOME.

allvirtualenv command with arguments

3.8 workon

List or change working virtual environments

workon [(-c|--cd)|(-n|--no-cd)] [environment_name|"."]

If no environment_name is given the list of available environments is printed to stdout.

If -c or --cd is specified the working directory is changed to the project directory during the post-activate phase, regardless of the value of VIRTUALENVWRAPPER_WORKON_CD.

If -n or --no-cd is specified the working directory is not changed to the project directory during the post-activate phase, regardless of the value of VIRTUALENVWRAPPER_WORKON_CD.

If "." is passed as the environment name, the name is derived from the base name of the current working directory .

3.9 deactivate

Switch from a virtual environment to the system-installed version of Python.

deactivate

3.10 mkproject

Create a new virtualenv in the WORKON_HOME and project directory in PROJECT_HOME.

mkproject [-f|--force] [-t template] [virtualenv_options] ENVNAME
# -f, --force   Create the virtualenv even if the project directory already exists
# The template option may be repeated to have several templates used to create a new project. 

3.11 setvirtualenvproject

Bind an existing virtualenv to an existing project.

setvirtualenvproject [virtualenv_path project_path]

3.12 cdproject

Change the current working directory to the one specified as the project directory for the active virtualenv.

cdproject

3.13 wipeenv

Remove all of the installed third-party packages in the current virtualenv.

wipeenv

4. Examples

4.1 set python version

mkvirtualenv --python=/usr/bin/python3 ENVNAME
mkproject --python=/usr/bin/python3 ENVNAME

Virtualenwrapper的更多相关文章

  1. Ubuntu16.04怎么安装virtualenv虚拟环境

    最近安装virtualenv的python虚拟环境,在网上找了很多,尝试了很多,都有各种问题,最终搞定后,给大家分享下我的过程,希望大家少走弯路. 本次安装是基于Ubuntu16.04Linux版本安 ...

  2. Django打造大型企业官网

    第1章 Django预热 1-为什么需要虚拟环境 2-virtualenv创建虚拟环境 3-virtualenvwrapper使用 4-URL组成部分讲解 5-课程准备工作 6-Django介绍 第2 ...

  3. Django实现博客项目

    一.项目概述 项目运行环境 Python3.6+ Django 1.11 MySQL 5.7 其他插件(图片处理.分页.验证码....) 项目详细功能介绍 前台功能 项目首页展示 轮播图 博客推荐 最 ...

  4. ubuntu16.04安装python虚拟环境

    自己也是搜的教程,亲测有效 ubuntu16.04创建虚拟环境 一.linux环境 Ubuntu16.04 二.安装和配置虚拟环境 安装虚拟环境 sudo pip install virtualenv ...

随机推荐

  1. 字符串查找strpos()函数用法

    #如果id=3 在字符串中查找出3是否存在.$str="2,12,33,22,55"; if(strpos(','.$id.',',','.$str.',')!==FALSE){ ...

  2. SQLServer -- SQL Server Database Error: 内部 SQL Server 错误

    报表在SQLserver2008运行统计正常,但是在SQLserver2000运行报错,SQL直接执行报:内部 SQL Server 错误. 不断的排查,最终得到的结论是:SQLserver2000似 ...

  3. [python学习] 简单爬取图片站点图库中图片

    近期老师让学习Python与维基百科相关的知识,无聊之中用Python简单做了个爬取"游讯网图库"中的图片,由于每次点击下一张感觉很浪费时间又繁琐.主要分享的是怎样爬取HTML的知 ...

  4. 【BZOJ3864】Hero meet devil DP套DP

    [BZOJ3864]Hero meet devil Description There is an old country and the king fell in love with a devil ...

  5. 【题解】Cats Transport (斜率优化+单调队列)

    [题解]Cats Transport (斜率优化+单调队列) # When Who Problem Lang Verdict Time Memory 55331572 Jun/09/2019 19:1 ...

  6. 【题解】P3258松鼠的新家

    [题解][P3258 JLOI2014]松鼠的新家 树链剖分板子题. 总结一点容易写错的地方吧: if(d[top[u]]<d[top[v]]) swap(u,v);注意是\(top\). 在\ ...

  7. 【题解】 CF11D A Simple Task

    [题解] CF11D A Simple Task 传送门 \(n \le 20\) 考虑状态压缩\(dp\). 考虑状态,\(dp(i,j,O)\)表示从\(i\)到\(j\)经过点集\(O\)的路径 ...

  8. DOM相关操作的案例

    1 . 模态框案例 示例 :  打开网页时有一个普通的按钮,点击当前按钮显示一个背景图,中心并弹出一个弹出框,点击X的时候会关闭当前的模态框 <!DOCTYPE html> <htm ...

  9. Android Weekly Notes Issue #275

    Android Weekly Issue #275 September 17, 2017 Android Weekly Issue #275 本期内容包括给Google Map实现一个Marker A ...

  10. 20145239杜文超 《Java程序设计》第3周学习总结

    20145239 <Java程序设计>第3周学习总结 教材学习内容总结 一.第四章: (1)对象和类: 使用Java撰写程序几乎都在使用对象,要产生对象必须先定义类,类是对象的设计图,对象 ...