首页 > 移动平台 > 详细

virtualenv virtualenvwrapper 虚拟环境创建

时间:2019-03-13 18:26:51      阅读:201      评论:0      收藏:0      [点我收藏+]

虚拟环境创建

安装

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

    C:\Users\Python>

 

创建

    C:\Users\Python>virtualenv testvir
    Using base prefix c:\\python36
    New python executable in C:\Users\Python\testvir\Scripts\python.exe
    Installing setuptools, pip, wheel...
    done.

    C:\Users\Python>

 

打开进入

创建后切到 Scripts 下. 所有的方法都在这里

同理, 也将这个路径加入到 环境变量 中 方便以后的使用

    C:\Users\Python>cd testvir
    C:\Users\Python\testvir>cd Scripts
    C:\Users\Python\testvir\Scripts>activate.bat

    (testvir) C:\Users\Python\testvir\Scripts>pip list
    Package    Version
    ---------- -------
    pip        19.0.3
    setuptools 40.8.0
    wheel      0.33.1
    (testvir) C:\Users\Python\testvir\Scripts>

virtualenv 创建好了的 Scripts 此文件以后作为

  • mkvirtualenv
  • workon
  • deactivate

等命令的存放地点
如果未添加 环境变量 以后需要切换到此目录才可以执行相关的虚拟环境的创建

pip list 可以查看当前环境下的 包管理

安装

创建虚拟环境需要用到另一个 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>

 

virtualenv virtualenvwrapper 虚拟环境创建

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!