设为首页 加入收藏

TOP

Python 3.6 的 venv 模块(一)
2018-08-06 10:54:46 】 浏览:254
Tags:Python 3.6 venv 模块

今天,在使用 pycharm 的使用,进行创建 python的时候,发现使用默认的创建的选项使用的python 3环境 。而我系统默认的python环境是 python 2.7 环境;这就引起了我的兴趣。


我打开pycharm 的终端,发现:



我们使用 python 内置的文档查看,venv 相关,其描述为:


Help on package venv:


NAME
    venv - Virtual environment (venv) package for Python. Based on PEP 405.


我们使用python3 查看 venv 模块的使用方法:


?  env pwd
/home/xuyaowen/Desktop/workplace/env
?  env python3 -m venv -h
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-packages
                        Give the virtual environment access to the system
                        site-packages dir.
  --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 contents of the environment directory if it
                        already exists, before environment creation.
  --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)
  --prompt PROMPT      Provides an alternative prompt prefix for this
                        environment.


Once an environment has been created, you may wish to activate it, e.g. by
sourcing an activate script in its bin directory.


通过上面的介绍,我们大致知道 venv 的模块使用方法:


首先我们创建虚拟环境:


?  venvtest pwd
/home/xuyaowen/Desktop/workplace/venvtest
?  venvtest python3 -m venv .


我们查看创建的结果:


?  venvtest ls
bin  include  lib  lib64  pyvenv.cfg
?  venvtest ll *
lrwxrwxrwx. 1 xuyaowen xuyaowen    3 Jul 27 11:44 lib64 -> lib
-rw-r--r--. 1 xuyaowen xuyaowen  69 Jul 27 11:44 pyvenv.cfg


bin:
total 32K
-rw-r--r--. 1 xuyaowen xuyaowen 2.2K Jul 27 11:44 activate
-rw-r--r--. 1 xuyaowen xuyaowen 1.3K Jul 27 11:44 activate.csh
-rw-r--r--. 1 xuyaowen xuyaowen 2.4K Jul 27 11:44 activate.fish
-rwxr-xr-x. 1 xuyaowen xuyaowen  271 Jul 27 11:44 easy_install
-rwxr-xr-x. 1 xuyaowen xuyaowen  271 Jul 27 11:44 easy_install-3.6
-rwxr-xr-x. 1 xuyaowen xuyaowen  243 Ju

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇数据压缩的重要组成部分---位操作 下一篇C/C++ 图的创建及图的相关函数(链..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目