如何访问virtualenv管理命令?

时间:2014-03-14 16:19:20

标签: python windows virtualenv

我无法访问任何virtualenv管理命令,例如Get-VirtualEnvironment。 我在Windows-XP中执行了以下操作:

  1. 已安装C:\ Python27。
  2. 在C:\ Python27 \ Lib \ site-packages中安装了pip和setuptools。
  3. 使用PowerShell,运行“pip install virtualenv”。
  4. 创建环境变量WORKON_HOME =(本地目录)。
  5. 但是,当我运行Get-Command virtualenv时,我得到一行作为回复,而不是virtualenv命令列表。

1 个答案:

答案 0 :(得分:0)

首先:使用pip install安装virtualenv(在Python \Scripts目录中)

C:\Python2\Scripts>pip install virtualenv
Downloading/unpacking virtualenv
  Downloading virtualenv-1.11.5.tar.gz (1.8MB): 1.8MB downloaded
  Running setup.py egg_info for package virtualenv

    warning: no previously-included files matching '*' found under directory 'do
cs\_templates'
    warning: no previously-included files matching '*' found under directory 'do
cs\_build'
Installing collected packages: virtualenv
  Running setup.py install for virtualenv

    warning: no previously-included files matching '*' found under directory 'do
cs\_templates'
    warning: no previously-included files matching '*' found under directory 'do
cs\_build'
    Installing virtualenv-script.py script to C:\Python2\Scripts
    Installing virtualenv.exe script to C:\Python2\Scripts
    Installing virtualenv.exe.manifest script to C:\Python2\Scripts
    Installing virtualenv-2.7-script.py script to C:\Python2\Scripts
    Installing virtualenv-2.7.exe script to C:\Python2\Scripts
    Installing virtualenv-2.7.exe.manifest script to C:\Python2\Scripts
Successfully installed virtualenv
Cleaning up...

第二名:创建名为env01的虚拟环境(或者您喜欢)。

C:\Python2\Scripts>virtualenv ..\env01
New python executable in ..\env01\Scripts\python.exe
Installing setuptools, pip...done.

第三:转到en virtualenv dir created

C:\Python2\Scripts>cd ..\env01

C:\Python2\env01>dir
 El volumen de la unidad C es ********
 El número de serie del volumen es: ****-****

 Directorio de C:\Python2\env01

03/05/2014  19:25    <DIR>          .
03/05/2014  19:25    <DIR>          ..
15/01/2014  16:33    <DIR>          Include
03/05/2014  19:25    <DIR>          Lib
03/05/2014  19:25    <DIR>          Scripts
               0 archivos              0 bytes
               5 dirs  11.779.756.032 bytes libres

第四:执行activate.bat dir中的<your_virtualenv>\Scripts\脚本

C:\Python2\env01>.\Scripts\activate
**(env01) C:\Python2\env01>**
  • 提醒您使用deactivate.bat脚本停用virtualenv:

    (env01)C:\ Python2 \ env01&gt;停用

    C:\ Python2 \ env01&GT;

  • 它也适用于Python3。