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. 树莓派安装配置Nginx+PHP7+MariaDB

    原文地址:http://blog.sina.com.cn/s/blog_150f554f50102yhra.html 一.安装 Nginx 和 PHP7 1.安装Nginx sudo apt inst ...

  2. git一些常用配置

    1. git config git config 分为全局和局部 全局:git config --glabol 局部:git config 最终会生成配置文件,一般在~/.gitconfig. 2. ...

  3. Java 面向对象(四)

    代码块 什么是代码块 在类中或方法当中 使用 { } 括起来的一段代码,就称它是一个代码块. 在代码块当中定义的变量我们称是局部变量,在外面是没有办法使用的.这里定义的 a 就是一个局部变量. 代码块 ...

  4. VMware Workstation虚拟机打开系统时,提示“无法打开内核设备“\\.\Global\vmx86”: 系统找不到指定的文件。是否在安装 VMware Workstation 后重新引导?”

    VMware Workstation虚拟机打开系统时,提示“无法打开内核设备“\\.\Global\vmx86”: 系统找不到指定的文件.是否在安装 VMware Workstation 后重新引导? ...

  5. scope.row中属性值展示

    <el-table-column align="> <template slot-scope="scope"> {{ scope.$index } ...

  6. CentOS 7下安装Redis

    1.安装gcc环境 sudo yum install gcc-c++ 2.安装wget sudo yum install wget 3.下载Redis源码包 wget http://download. ...

  7. 自定义基于IFC数据的施工进度数据结构

    <DataSource>D:/qlbz20190802.ifc</DataSource> <Datas> <Data> <ID></I ...

  8. Apache工作模式切换

    一.apache运行模式切换 apache比较常用的工作模式有worker以及prefork两种方式 1.编译安装: 如果在编译时候不指定,系统默认的是prefork模式.如果需要换成worker模式 ...

  9. python命令行参数解析OptionParser类用法实例

    python命令行参数解析OptionParser类用法实例 本文实例讲述了python命令行参数解析OptionParser类的用法,分享给大家供大家参考. 具体代码如下:     from opt ...

  10. 基于JAVA JWT 实现OATUH TOKEN验证

    什么是jwt? 最详细的是官网:https://jwt.io/ 这里以java的ssm框架为例,集成jwt. 1.pom.xml 导入jwt的包 <!-- jwt --> <!-- ...