virtualenv virtualenvwrapper 虚拟环境创建

virtualenv  方式

安装

    C:UsersPython> pip install virtualenv
    Requirement already satisfied: virtualenv in c:python36libsite-packages (16.4.1)

    C:UsersPython>

创建

首先创建一个空文件夹

[~]$ mkdir  yangtuo
[~]$ cd yangtuo/
[~/yangtuo]$ 

创建 虚拟环境

[~/yangtuo]$ virtualenv --no-site-packages yangtuotest
  No LICENSE.txt / LICENSE found in source
New python executable in /data/home/v_vtongyang/yangtuo/yangtuotest/bin/python
Installing setuptools, pip, wheel...
done.
[~/yangtuo]$ 

切换

[~/yangtuo]$ source yangtuotest/bin/activate
(yangtuotest) [~/yangtuo]$

退出

(yangtuotest) [~/yangtuo]$ deactivate 
[~/yangtuo]$ 

virtualenvwrapper  方式

安装

创建虚拟环境需要用到另一个 virtualenvwrapper 如果是 windows 环境下要加 -win

    (testvir) C:UsersPython	estvirScripts>pip install virtualenvwrapper-win
    ...

创建虚拟环境并进入

    (testvir) C:UsersPython	estvirScripts>mkvirtualenv testvir2
     C:UsersPythonEnvs is not a directory, creating
    Using base prefix 'c:\python36'
    New python executable in C:UsersPythonEnvs	estvir2Scriptspython.exe
    Installing setuptools, pip, wheel...
    done.

    (testvir2) C:UsersPython	estvirScripts>

查看当前虚拟环境

    C:UsersPython	estvirScripts>workon

    Pass a name to activate one of the following virtualenvs:
    ==============================================================================
    testvir2

    C:UsersPython	estvirScripts>

退出虚拟环境

(testvir2) C:UsersPython	estvirScripts>deactivate.bat

进入虚拟环境

    C:UsersPython	estvirScripts>workon testvir2
    (testvir2) C:UsersPython	estvirScripts>

pychram  使用虚拟环境

 如果已有的直接使用即可

没有的哈则需要自己添加 

 可以在 pycharm 里面查看下当前环境下的 组件情况以确认是否成功

原文地址:https://www.cnblogs.com/shijieli/p/10524818.html