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

最新文章

  1. JavaWeb的学习之Servlet(转载自孤傲苍狼)
  2. Linux 运行 apt-get install 就出现jdk installer 错误的解决方法
  3. 【QT】自己生成ui加入工程
  4. int a
  5. networking常用命令
  6. vmware下ubuntu14.04调整分辨率
  7. Ubuntu Nginx搭建Gitweb服务器
  8. 20150410---GridView分页(备忘)
  9. [Bootstrap] 7. Working Herader
  10. BZOJ_1611_[Usaco2008_Feb]_Meteor_Shower流星雨_(bfs)
  11. DevExpress的GridControl控件更新數據問題解決辦法
  12. socket、tcp、http
  13. EC读书笔记系列之3:条款5、条款6、条款7
  14. pragma comment
  15. Django操作model时刻,一个错误:AttributeError:’ProgrammingError’ object has no attribute ‘__traceback__’
  16. JavaScript继承基础讲解,原型链、借用构造函数、混合模式、原型式继承、寄生式继承、寄生组合式继承
  17. Codeforces 343E Pumping Stations
  18. Java内存泄漏分析系列之一:使用jstack定位线程堆栈信息
  19. 【Python实战】模块和包导入详解(import)
  20. [LeetCode] Car Fleet 车队

热门文章

  1. java eclipse使用不同jdk版本
  2. linux查看磁盘挂载的三种方法
  3. x86 的 TSS 任务切换机制
  4. java项目中的classpath到底是什么
  5. 九度OJ 1035:找出直系亲属 (二叉树、递归)
  6. iOS 流布局 UICollectionView使用(UICollectionVIew的代理方法)
  7. 二维码图片流转base64
  8. Django 模型层--单表
  9. Android LinearLayout线性布局
  10. qemu仿真执行uboot和barebox