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的字典中,把“鱼 ...
随机推荐
- Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure........
iframe引入视频的文件的时候报这个错 其实只要改成 加上一个s就好了 ...
- js 返回两数(包含这两数)之间的随机数函数
function selectFrom( lowerValue, upperValue ){ var choices = upperValue - lowerValue + 1; return Mat ...
- js 根据滚动条加载数据
很久没记笔记了,最近搞起web开发了 <html> <head> <script src="http://code.jquery.com/jquery-1.7. ...
- FLUENT导入CHEMKIN机理的单位问题【转载】
转载自:http://blog.sina.com.cn/s/blog_4a0a8b5d0101pj3c.html CHEMKIN机理导入后,发现速率常数全变了,那么他们是怎样变化的呢? FLUENT中 ...
- GitHub的SSH免密连接
1.进入当前用户的家目录 $ cd ~ 2.删除.ssh 目录 $ rm -rvf .ssh 3.运行命令生成.ssh 密钥目录 $ ssh-keygen -t rsa -C [GitHub邮箱] [ ...
- 5分钟学会如何创建spring boot项目
上一篇博客说了如何创建spring boot项目,但是有些同学会觉得有点麻烦,有没有什么快速学会能快速创建spring boot项目的方法,答案是肯定的.接下来我们就一起来快速创建一个spring b ...
- Linux perl: warning: Setting locale failed.perl: warning: Please check that your locale settings:
使用 apt-get 安装软件时,总是出现下面的错误. perl: warning: Setting locale failed. perl: warning: Please check that y ...
- OpenJudge计算概论-分离整数的各个数位
/*================================================================= 分离整数的各个数位 总时间限制: 1000ms 内存限制: 65 ...
- 使用notepad++插件远程编辑linux下的配置文件
目录 1.安装插件管理器(Plugin Manager) 2.安装NppFTP 3.使用nppFTP连接远程linux服务器 1.安装插件管理器(Plugin Manager) 如果没有则需要安装 3 ...
- wordpress插件开发流程梳理-二
开发插件的最佳实践 避免命名冲突 当您的插件对变量,函数或类使用相同的名称作为另一个插件时,会发生命名冲突. 幸运的是,您可以使用以下方法避免命名冲突. 程序性 默认情况下,所有变量,函数和类都在全局 ...