TOP

virtualenv virtualenvwrapper 虚拟环境创建

virtualenv  方式

安装

    C:\Users\Python> pip install virtualenv
    Requirement already satisfied: virtualenv in c:\python36\lib\site-packages (16.4.1)

    C:\Users\Python>

创建

首先创建一个空文件夹

[~]$ 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:\Users\Python\testvir\Scripts>pip install virtualenvwrapper-win
    ...

创建虚拟环境并进入

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

    (testvir2) C:\Users\Python\testvir\Scripts>

查看当前虚拟环境

    C:\Users\Python\testvir\Scripts>workon

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

    C:\Users\Python\testvir\Scripts>

退出虚拟环境

(testvir2) C:\Users\Python\testvir\Scripts>deactivate.bat

进入虚拟环境

    C:\Users\Python\testvir\Scripts>workon testvir2
    (testvir2) C:\Users\Python\testvir\Scripts>

pychram  使用虚拟环境

 如果已有的直接使用即可

没有的哈则需要自己添加 

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

 

posted @ 2019-03-13 17:54  羊驼之歌  阅读(764)  评论(0编辑  收藏  举报