Python3.3以上的版本通过venv模块原生支持虚拟环境,可以代替Python之前的virtualenv。该venv模块提供了创建轻量级“虚拟环境”,提供与系统Python的隔离支持。每一个虚拟环境都有其自己的Python二进制(允许有不同的Python版本创作环境),并且可以拥有自己独立的一套Python包。Python3.3中使用”venv”命令创建的环境不包含”pip”,你需要进行手动安装。在Python3.4中改进了这一个缺陷。

   一、在当前目录创建虚拟环境:

$ python -m venv .

    二、”venv”的详细使用参数:

usage: venv [-h] [--system-site-packages] [--symlinks] [--clear]

[--upgrade] [--without-pip] ENV_DIR [ENV_DIR ...]

Creates virtual Python environments in one or more target directories.

positional arguments:

ENV_DIR             A directory to create the environment in.

optional arguments:

-h, --help    show this help message and exit

--system-site-packages    Give access to the global site-packages dir to the  virtual environment.

--symlinks    Try to use symlinks rather than copies, when symlinks are not the default for the platform.

--copies    Try to use copies rather than symlinks, even when symlinks are the default for the platform.

--clear    Delete the environment directory if it already exists. If not specified and the directory exists, an error is raised.

--upgrade    Upgrade the environment directory to use this version of Python, assuming Python has been upgraded in-place.

--without-pip    Skips installing or upgrading pip in the virtual environment (pip is bootstrapped by default)

  

  三、激活虚拟环境

  Posix标准平台下:$ source <venv>/bin/activate

  Windows cmd : C:> <venv>/Scripts/activate.bat

  Windows PowerShell: PS C:> <venv>/Scripts/Activate.ps1

python 虚拟环境 venv 简单用法的更多相关文章

  1. python lambda表达式简单用法【转】

    python lambda表达式简单用法 1.lambda是什么? 看个例子: g = lambda x:x+1 看一下执行的结果: g(1) >>>2 g(2) >>& ...

  2. python timeit模块简单用法

    timeit模块提供了一种简便的方法来为Python中的小块代码进行计时. 模块调用函数,stmp为要测试的函数,setup为测试环境,number为运行次数 timeit.timeit(stmt=) ...

  3. Python - 虚拟环境 venv

    什么是虚拟环境 这是 Python 3.3 的新特性:https://www.python.org/dev/peps/pep-0405/ 假设自己电脑主机的 Python 环境称为系统环境,而默认情况 ...

  4. supervisor支持python虚拟环境venv

    在项目中使用supervisor时,如何在虚拟环境下启动一直存在些小问题. 比如我要写 Cesi程序的监听,我是手动安装的执行之前 要先加载环境source venv/bin/activate 所以写 ...

  5. Python Lambda 的简单用法

    下面代码简单举例介绍以下 lambda的用法. from functools import reduce #1 python lambda会创建一个函数对象,但不会把这个函数对象赋给一个标识符,而de ...

  6. Python虚拟环境Virtualen简单使用

    安装pip 使用脚本安装和升级pip 要安装或升级pip,需要下载 get-pip.py. 地址:https://bootstrap.pypa.io/get-pip.py 然后运行以下命令 (需要管理 ...

  7. python lambda表达式简单用法

    习条件运算时,对于简单的 if else 语句,可以使用三元运算来表示,即: 1 2 3 4 5 6 7 8 # 普通条件语句 if 1 == 1:     name = 'wupeiqi' else ...

  8. python,os.path简单用法

    #首先导入os包 import os#引入time模块是因为需要将浮点型的时间转为东八区时间 import time # basename(path),去掉路径名称,单独返回文件名 f = os.pa ...

  9. [Python]字典的简单用法

    Python中的字典与现实中字典类似,从字典中可以找到“鱼”字:鱼类是体被骨鳞.以鳃呼吸.通过尾部和躯干部的摆动以及鳍的协调作用游泳和凭上下颌摄食的变温水生脊椎动物.类比到Python的字典中,把“鱼 ...

随机推荐

  1. Eclipse简明使用教程(java集成开发环境)

    说明:我使用的是绿色便携版的Eclipse,免安装,解压就能用.链接:https://download.csdn.net/download/loongstyle/10700321 1_Eclipse中 ...

  2. CodeForces - 1189E Count Pairs(平方差)

    Count Pairs You are given a prime number pp, nn integers a1,a2,…,ana1,a2,…,an, and an integer kk. Fi ...

  3. Java 交换两数的方法

    错误示范 1. 直接交换 public class SwapNumbers { // 直接交换 public static void swap(int a, int b) { int temp = a ...

  4. MySQL数据库可以用任意ip连接访问的方法

    > use mysql; > update user set host='%' where host='localhost'; > flush privileges;

  5. 关于form与表单提交操作的一切

    原文链接:http://caibaojian.com/form.html 你知道,一个表单里面只要有form元素,如果没有给action加一个默认值,为空白的时候,当你刷新页面时,会弹出一个警告框提示 ...

  6. HTTP请求客户端工具类

    1.maven 引入依赖 <dependency> <groupId>commons-httpclient</groupId> <artifactId> ...

  7. alpha测试和beta测试的区别是什么?

    1.测试时间不同: Beta测试是软件产品完成了功能测试和系统测试之后,在产品发布之前所进行的软件测试活动,它是技术测试的最后一个阶段. alpha测试简称“α测试”,可以从软件产品编码结束之时开始, ...

  8. Nginx在线服务状态下平滑升级或新增模块

    nginx在使用过程中,有时需要在不影响当前业务的情况下,进行升级或新增模块.nginx的升级有两种方法:1.半自动化升级:2.手动升级 不过都需要先查看安装的nginx版本和配置信息,然后前往官网下 ...

  9. SpringMVC拦截器工作流程图

  10. python根据数组数据绘图

    转载自网络,版权归原作者所有 hello3.txt文件内部数据如下 ......7,2,6,-12,-10,-7,-1,2,9,...... python脚本 import numpy as np i ...