当前位置: 首页 > news >正文

Python3虚拟环境--venv

Python3.3以上的版本通过venv模块原生支持虚拟环境,可以代替之前的virtualenv。

该venv模块提供了创建轻量级“虚拟环境”,提供与系统Python的隔离支持。每一个虚拟环境都有其自己的Python二进制(允许有不同的Python版本创作环境),并且可以拥有自己独立的一套Python包。

注意:python3.3中使用”venv”命令创建的环境不包含”pip”,需进行手动安装。Python3.4中改进了这一缺陷。

创建虚拟环境

1 python -m venv myvenv

此命令会在当前目录下生成一个名为myvenv的目录,myenv也是创建的虚拟环境名。

激活环境:

/Scripts/activate.bat

退出环境:

/Scripts/deactivate.bat

 

附:

venv使用参数:

 1 usage: venv [-h] [--system-site-packages] [--symlinks] [--clear]
 2             [--upgrade] [--without-pip] ENV_DIR [ENV_DIR ...]
 3 
 4 Creates virtual Python environments in one or more target directories.
 5 
 6 positional arguments:
 7   ENV_DIR             A directory to create the environment in.
 8 
 9 optional arguments:
10   -h, --help             show this help message and exit
11   --system-site-packages Give access to the global site-packages dir to the
12                          virtual environment.
13   --symlinks             Try to use symlinks rather than copies, when symlinks
14                          are not the default for the platform.
15   --copies               Try to use copies rather than symlinks, even when
16                          symlinks are the default for the platform.
17   --clear                Delete the environment directory if it already exists.
18                          If not specified and the directory exists, an error is
19                          raised.
20   --upgrade              Upgrade the environment directory to use this version
21                          of Python, assuming Python has been upgraded in-place.
22   --without-pip          Skips installing or upgrading pip in the virtual
23                          environment (pip is bootstrapped by default)

 

 


img_42a4adae4716d0e15c3eeaabfd040044.png

注:转载需注明出处及作者。

流柯      

相关文章:

  • 管理控制文件 和日志文件
  • Fedora 全局代理上网设置
  • Eclipse Tomcat启动后乱码
  • 设置IntelliJ主题和字体方法
  • 相机频率 条纹图片颜色还原不精确的问题,特别是指图片颜色过渡不自然的现象...
  • Git学习-Git时光机之版本回退(二)
  • linux 资料
  • 前后端分离实践
  • dedecms 联动checkbox多选
  • 深度解剖dubbo源码
  • c中无符号(unsigned)和有符号(signed)两种类型。
  • TrustInstall
  • jvm中的新生代Eden和survivor区
  • 2017年期末获奖名单
  • Copy修饰的NSArray
  • 自己简单写的 事件订阅机制
  • 《微软的软件测试之道》成书始末、出版宣告、补充致谢名单及相关信息
  • 【108天】Java——《Head First Java》笔记(第1-4章)
  • 【391天】每日项目总结系列128(2018.03.03)
  • angular2开源库收集
  • C++11: atomic 头文件
  • JavaScript/HTML5图表开发工具JavaScript Charts v3.19.6发布【附下载】
  • Javascript设计模式学习之Observer(观察者)模式
  • Js基础——数据类型之Null和Undefined
  • PAT A1092
  • PAT A1120
  • Windows Containers 大冒险: 容器网络
  • 阿里云应用高可用服务公测发布
  • 七牛云假注销小指南
  • 微信小程序设置上一页数据
  • 新书推荐|Windows黑客编程技术详解
  • 译有关态射的一切
  • 原生Ajax
  • linux 淘宝开源监控工具tsar
  • # 日期待t_最值得等的SUV奥迪Q9:空间比MPV还大,或搭4.0T,香
  • (aiohttp-asyncio-FFmpeg-Docker-SRS)实现异步摄像头转码服务器
  • (Forward) Music Player: From UI Proposal to Code
  • (六)库存超卖案例实战——使用mysql分布式锁解决“超卖”问题
  • (一)C语言之入门:使用Visual Studio Community 2022运行hello world
  • (转)Unity3DUnity3D在android下调试
  • (转)树状数组
  • (最简单,详细,直接上手)uniapp/vue中英文多语言切换
  • ***通过什么方式***网吧
  • .net core 6 redis操作类
  • .net core 源码_ASP.NET Core之Identity源码学习
  • .net framework 4.0中如何 输出 form 的name属性。
  • .NET 将混合了多个不同平台(Windows Mac Linux)的文件 目录的路径格式化成同一个平台下的路径
  • .net 生成二级域名
  • .net 提取注释生成API文档 帮助文档
  • .NET/C# 使用反射注册事件
  • .NET6 命令行启动及发布单个Exe文件
  • .NET基础篇——反射的奥妙
  • .Net下的签名与混淆
  • .pings勒索病毒的威胁:如何应对.pings勒索病毒的突袭?
  • @RequestBody与@ResponseBody的使用