python 虚拟环境 venv 简单用法
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 简单用法的更多相关文章
- python lambda表达式简单用法【转】
python lambda表达式简单用法 1.lambda是什么? 看个例子: g = lambda x:x+1 看一下执行的结果: g(1) >>>2 g(2) >>& ...
- python timeit模块简单用法
timeit模块提供了一种简便的方法来为Python中的小块代码进行计时. 模块调用函数,stmp为要测试的函数,setup为测试环境,number为运行次数 timeit.timeit(stmt=) ...
- Python - 虚拟环境 venv
什么是虚拟环境 这是 Python 3.3 的新特性:https://www.python.org/dev/peps/pep-0405/ 假设自己电脑主机的 Python 环境称为系统环境,而默认情况 ...
- supervisor支持python虚拟环境venv
在项目中使用supervisor时,如何在虚拟环境下启动一直存在些小问题. 比如我要写 Cesi程序的监听,我是手动安装的执行之前 要先加载环境source venv/bin/activate 所以写 ...
- Python Lambda 的简单用法
下面代码简单举例介绍以下 lambda的用法. from functools import reduce #1 python lambda会创建一个函数对象,但不会把这个函数对象赋给一个标识符,而de ...
- Python虚拟环境Virtualen简单使用
安装pip 使用脚本安装和升级pip 要安装或升级pip,需要下载 get-pip.py. 地址:https://bootstrap.pypa.io/get-pip.py 然后运行以下命令 (需要管理 ...
- python lambda表达式简单用法
习条件运算时,对于简单的 if else 语句,可以使用三元运算来表示,即: 1 2 3 4 5 6 7 8 # 普通条件语句 if 1 == 1: name = 'wupeiqi' else ...
- python,os.path简单用法
#首先导入os包 import os#引入time模块是因为需要将浮点型的时间转为东八区时间 import time # basename(path),去掉路径名称,单独返回文件名 f = os.pa ...
- [Python]字典的简单用法
Python中的字典与现实中字典类似,从字典中可以找到“鱼”字:鱼类是体被骨鳞.以鳃呼吸.通过尾部和躯干部的摆动以及鳍的协调作用游泳和凭上下颌摄食的变温水生脊椎动物.类比到Python的字典中,把“鱼 ...
随机推荐
- 小程序for循环
https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxml/list.html 在什么情况下要自定义? 当上一个循环的数据 ...
- 小程序 image跟view标签上下会有间隙
图片文字等inline元素默许是跟父级元素的baseline对齐,而baseline又和父级底边有必定间距 我是使用: 加上这个消除了间隙,如果没有解决,你可以分别用 vertical-align:t ...
- 问题分析——Maven打包后发版,静态资源找不到
一.背景 Xxl-Job-Admin(开源分布式调度中心)项目在本地运行正常,Jenkins发版到测试环境,发版成功后,打开管理页面,页面css.js找不到. 怀疑是Maven没有把静态资源打包进去导 ...
- arcgis python ListEnvironments 函数可返回地理处理环境名称列表。
import arcpy environments = arcpy.ListEnvironments() # Sort the environment names environments.sort( ...
- spring aop中aspect和advisor的区别
之前看到spring AOP配置aspect(切面)有两种方式,一种是利用注解的方式配置,一种是利用XML的方式配置. 我们的配置是这样的<aop:aspect>,还有另外一种<ao ...
- lua table操作
求最大值,最小值及长度: function maxn(t) local mn = nil for i, v in pairs(t) do if (mn==nil) then mn=v end if ( ...
- python中dir,__dict__ , __setitem__(),__getitem__()
class Testa: pass class Testb(object): pass if __name__ == '__main__': print 'testb = ',dir(Testb) p ...
- labelimg data
<annotation> <folder>img_data_box_1500</folder> <filename>798.jpg</filena ...
- npm教程、脚手架
使用之前,我们先来掌握3个东西是用来干什么的. npm: Nodejs下的包管理器. webpack: 它主要的用途是通过CommonJS的语法把所有浏览器端需要发布的静态资源做相应的准备,比如资源的 ...
- Python3之定制类
看到类似的__slots__这种形如__xxx__的变量或者函数名就要注意,这些在Python中是有特殊用途的 Python中还有许多有特殊用途的函数,可以帮助我们定制类 __str__ 先定义一个S ...