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. 查看SELinux状态并关闭SELinux

    SELinux(Security-Enhanced Linux)是Linux上最杰出的新安全子系统.在linux内核级别上提供了一个灵活的强制访问控制系统(MAC),这个强制访问控制系统是建立在自由访 ...

  2. 【BZOJ4966】总统选举 线段树+随机化

    [BZOJ4966]总统选举 Description 黑恶势力的反攻计划被小C成功摧毁,黑恶势力只好投降.秋之国的人民解放了,举国欢庆.此时,原秋之国总统因没能守护好国土,申请辞职,并请秋之国人民的大 ...

  3. 关于EF输出sql的执行日志

    sqlserver中可以使用sql profiler:但是mysql当中无法查看:只能借助于组件: ADO.NET Entity Framework CodeFirst 如何输出日志(EF4.3) 用 ...

  4. HttpPost (URLConnection)传参数中文乱码

    client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 1000000); client.getParams( ...

  5. 在java项目中使用protobuf

    1 通用方式 第一步,定义数据结构 第二步,使用protoc.exe生成java代码 第三步,序列化 第四步,反序列化 2 grpc方式 grpc官方推荐的方式,通过maven插件来生成java代码. ...

  6. 一文快速搞懂MySQL InnoDB事务ACID实现原理(转)

    这一篇主要讲一下 InnoDB 中的事务到底是如何实现 ACID 的: 原子性(atomicity) 一致性(consistency) 隔离性(isolation) 持久性(durability) 隔 ...

  7. 您使用的是不受支持的命令行标记 chrome

    检查 chrome://flags/#extensions-on-chrome-urls 是否开启 开启了的话就关掉检查 启动chrome的快捷方式是否在目标后有额外的参数 有就删了 在浏览器中输入c ...

  8. 剑指Offer:数组中出现次数超过一半的数字【39】

    剑指Offer:数组中出现次数超过一半的数字[39] 题目描述 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字.例如,输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}.由于这 ...

  9. Spring Boot2.0之多数据源分布式事务问题

    分布式事务解决方案的问题, 分布式事务产生的原因: 多个不同的服务连接不同的数据源 ,做分布式事务的管理. 这种情况是连接两个数据源的情况,然后事务管理器是这样的 只管理了test02的这端业务代码. ...

  10. 一篇文章教你如何用R进行数据挖掘

    一篇文章教你如何用R进行数据挖掘 引言 R是一种广泛用于数据分析和统计计算的强大语言,于上世纪90年代开始发展起来.得益于全世界众多 爱好者的无尽努力,大家继而开发出了一种基于R但优于R基本文本编辑器 ...