文章目录

  • 系统参考
  • pyvenv脚本过时说明
  • python -m venv 创建新的虚拟环境

系统参考

[tony@tony-controller bin]$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)[tony@tony-controller bin]$ uname -a
Linux tony-controller 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux[tony@tony-controller bin]$ pwd
/home/tony/python37/bin[tony@tony-controller bin]$ ./python3 --version
Python 3.7.3

pyvenv脚本过时说明

尽管Python 3.7.3的bin目录下依然有pyvenv的脚本,但是在打印的help信息的第一行明确警告说:这个脚本是过时的,推荐使用 python3.7 -m venv命令。

注:主要原因是避免混淆新创建的虚拟环境到底用的是哪个Python解释器,使用python3.7 -m venv这个格式可以明确的指导使用的是当前调用的解释器。
注:PEP 405对Python的虚拟环境有详细说明。

[tony@tony-controller bin]$ ./pyvenv --help
WARNING: the pyenv script is deprecated in favour of `python3.7 -m venv`
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear][--upgrade] [--without-pip] [--prompt PROMPT]ENV_DIR [ENV_DIR ...]Creates virtual Python environments in one or more target directories.

python -m venv 创建新的虚拟环境

这个命令的选项与pyvenv的选项一样,可以一次性同时创建多个虚拟环境。

# 创建两个虚拟环境
[tony@tony-controller bin]$ ./python3 -m venv /tmp/venv1_py37 /tmp/venv2_py37# 查看虚拟环境目录
[tony@tony-controller bin]$ ls -l /tmp/venv*
/tmp/venv1_py37:
total 4
drwxrwxr-x. 2 tony tony 173 Apr 28 09:43 bin
drwxrwxr-x. 2 tony tony   6 Apr 28 09:43 include
drwxrwxr-x. 3 tony tony  23 Apr 28 09:43 lib
lrwxrwxrwx. 1 tony tony   3 Apr 28 09:43 lib64 -> lib
-rw-rw-r--. 1 tony tony  84 Apr 28 09:43 pyvenv.cfg/tmp/venv2_py37:
total 4
drwxrwxr-x. 2 tony tony 173 Apr 28 09:43 bin
drwxrwxr-x. 2 tony tony   6 Apr 28 09:43 include
drwxrwxr-x. 3 tony tony  23 Apr 28 09:43 lib
lrwxrwxrwx. 1 tony tony   3 Apr 28 09:43 lib64 -> lib
-rw-rw-r--. 1 tony tony  84 Apr 28 09:43 pyvenv.cfg# 选项帮助信息
[tony@tony-controller bin]$ ./python3 -m venv --help
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear][--upgrade] [--without-pip] [--prompt PROMPT]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-packagesGive the virtual environment access to the systemsite-packages dir.--symlinks            Try to use symlinks rather than copies, when symlinksare not the default for the platform.--copies              Try to use copies rather than symlinks, even whensymlinks are the default for the platform.--clear               Delete the contents of the environment directory if italready exists, before environment creation.--upgrade             Upgrade the environment directory to use this versionof Python, assuming Python has been upgraded in-place.--without-pip         Skips installing or upgrading pip in the virtualenvironment (pip is bootstrapped by default)--prompt PROMPT       Provides an alternative prompt prefix for thisenvironment.Once an environment has been created, you may wish to activate it, e.g. by
sourcing an activate script in its bin directory.

【Python】Python3.7.3 - 虚拟环境:pyvenv过时;使用python -m venv命令相关推荐

  1. python入门基础代码图-【01】Python基础入门 (全)

    一.字符串 1. 字符串切片 切片: name="abcdef" name[2:5]="cde" 跳取: name="abcdef" nam ...

  2. python开发出来的crm系统_用Python打造一个CRM系统(二)

    在上一篇中介绍了CRM和Django,在本篇中将聊聊Django的最佳实践. 总的来说就是遵循Django的设计理念:松耦合.代码精简.快速开发.DRY.明确优于隐式.一致性等.下面从开发环境.项目组 ...

  3. python 32位 64位 同时_windows系统python 32位与python 64位共存的方式

    最近想学习通过python和大漠插件相结合的方式写游戏脚本,但是在实现的过程中发现大漠插件只支持32位的python,对64位python不支持,而我又不想放弃我windows 10 上面已有的64位 ...

  4. python3 虚拟环境 pip 版本_【python知识】 - Python3之PIPENV虚拟环境及封装

    Python的封装是通过pyinstaller直接打包python环境下的所有第三方模块,不管是不是封装程序涉及到的模块通通都一股脑打包进来,造成封装后大小超出预计很多. Pipenv 是一款管理虚拟 ...

  5. 多版本python共存,安装三方库到指定python版本 多Python版本和虚拟环境

    多个Python版本:在同一台机器上安装不同的Python,例如2.7和3.4. 虚拟环境:独立的环境,既可以同时安装特定版本的Python,也可以安装任何特定于项目的软件包,而不会影响任何其他项目. ...

  6. python解析原理_代码详解:Python虚拟环境的原理及使用

    Python的虚拟环境极大地方便了人们的生活.本指南先介绍虚拟环境的基础知识以及使用方法,然后再深入介绍虚拟环境背后的工作原理. 注意:本指南在macOS Mojave系统上使用最新版本的Python ...

  7. python多环境管理_怎样管理多个Python版本和虚拟环境

    详解如何管理多个Python版本和虚拟环境 多个Python版本:在同一台机器上安装不同的Python,例如2.7和3.4. 虚拟环境:独立的环境,既可以同时安装特定版本的Python,也可以安装任何 ...

  8. python转移环境_python 虚拟环境及项目快速迁移

    一.是否安装了virtualenv: virtualenv -version 二.安装虚拟环境: pip install virtualenv pip install virtualenvwrappe ...

  9. python虚拟环境搭建mac_mac搭建python virtualenv虚拟环境并使用 - 李金龙

    在进行下面的内容的开始,请先升级pip,命令如下,截止到2017年5月23日8时,pip的最新版本为9.0.1,至于为什么需要升级,我也不晓得. python -m pip install --upg ...

最新文章

  1. 模型大十倍,性能提升几倍?谷歌研究员进行了一番研究
  2. Reactive Extensions(Rx) 学习
  3. LineatLayout设置背景为.9图后产生位移
  4. 【cordova打包】环境配置
  5. awk对某个字段分割处理
  6. User profile synchronization service starting issues 用户配置文件同步服务启动问题
  7. 2017-12-04HTML布局_div布局
  8. i.mx6 Android5.1.1 servicemanager本地服务
  9. mysql数据库持续_MySql数据库--持续记录ing
  10. java中的关键字有哪些_Java关键字有哪些?
  11. 吴恩达|机器学习作业8.0.异常检测
  12. 基金买入两天可以卖出吗?
  13. 在vue项目中使用 JSON 编辑器: vue-json-editor
  14. 微信卡券会员卡跳转外链php,微信卡券跳转小程序遇到的小坑
  15. angular封装七牛云图片上传,解决同一页面多个上传按钮分别上传
  16. NR-DL PDSCH Resource allocation 下行资源分配
  17. matlab模拟投硬币实验,利用几何画板模拟抛硬币实验
  18. arduino上传项目总是出错,串口通信或TX/RX显示上传项目出错
  19. 30000台苹果电脑遭恶意软件入侵,包括最新的M1系列
  20. 华为P40系列搭载HMS后,华为钱包很不错

热门文章

  1. Mac中使用LaTeX的中文字体出现Package fontspec Error: The font “宋体“ cannot be found.解决方案
  2. LeetCode-567:字符串的排列
  3. 【python基础知识】如何查看pycharm中已经安装的插件
  4. 【IDEA工具设置】解决控制台中文输出乱码问题
  5. 超图(hypergraph)
  6. 输入3个双精度实数,分别求出它们的和,平均值,平方和以及平方和的开方
  7. 位移运算符 ( ShiftOperator )
  8. java 删除list_Java中如何优雅地删除List中的元素
  9. ajax中data传参报错
  10. 服务器摆放需要预留U位么_卧室系列 | 选床+摆放新姿势,提升睡眠品质小技巧...