Have fun managing your virtual environment: virtualenvwrapper

virtualenvwrapper

virtualenvwrapper provides a set of commands to make working with virtual environments a lot more pleasant. It puts all your virtual environments in one place.

Install (make sure  virtualenv  is installed):

$ pip install virtualenvwrapper
$ export WORKON_HOME=~/Envs
$ source /usr/local/bin/virtualenvwrapper.sh

For Windows you can use virtualenvwrapper-win .

Install (make sure  virtualenv  is installed):

$ pip install virtualenvwrapper-win

On Windows, the default path for WORKON_HOME is %USERPROFILE%Envs.

basic use

  1. Create a virtual environment:
    $ mkvirtualenv my_project

    This will  ~/Envs create  the my_project folder in .

  2. Working on a virtual environment:
    $ workon my_project

    Alternatively, you can create a project, which creates a virtual environment and  $WORKON_HOME creates a project directory in it. When you use   ,   -ed to the project directory.workon myprojectcd

    $ mkproject myproject

    virtualenvwrapper  provides tab completion for environment names. This is useful when you have many environments and it is difficult to remember their names.

    workon It also stops your current environment, so you can quickly switch between environments. Stop is the same:

  3. Stop is the same:
    $ deactivate

     

  4. delete
    $ rmvirtualenv my_project

    Other useful commands

    lsvirtualenv
    List all environments.
    cdvirtualenv
    Navigate to the directory of the currently active virtual environment, say so you can browse it  site-packages .
    cdsitepackages
    Similar to the above, but directly into the  site-packages  directory.
    lssitepackages
    Display  site-packages  the contents of the directory.

    Complete list of virtualenvwrapper commands.

    virtualenv-burrito

    With virtualenv-burrito , you can have a virtualenv + virtualenvwrapper environment with a single command line.

    autoenv

    When you  cd enter an included  .env directory, autoenv automatically activates that environment.

    brew Install it on Mac OS X using

    $ brew install autoenv

    On Linux:

    $ git clone git: // github.com/kennethreitz/autoenv.git ~ / .autoenv 
    $ echo ' source ~ / .autoenv / activate.sh ' >> ~ / .bashrc

     

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324947419&siteId=291194637