Wiki

Clone wiki

envdotpy / Home

Overview

Env.py is a Python script that makes it easy to create, remove and switch between Python virtual environments. It works with the Windows command shell and the only dependencies are Python and virtualenv. I've been using this script under Windows XP for some time now with no issues (YMMV). If you have access to a proper shell you should use virtualenvwrapper:

http://bitbucket.org/dhellmann/virtualenvwrapper/

Installation

Copy the included file "env.py" to a directory on your path, "C:\Python2x\Scripts" is a good option.

Usage

env.py [options] arg

Options

OptionLongDescription
-h--helpshow this help message and exit
-r--removedelete the virualenv
-c--createcreate the virtualenv if it does not already exist
-l--listlist all current virtualenvs in directory
-d DIRECTORY--directory=DIRECTORYpath to the directory containing the virtualenv
-n--no-site-packagesDon't give access to the global site-packages dir to the virtual environment
--distributeUse Distribute instead of Setuptools. Set environ variableVIRTUALENV_USE_DISTRIBUTE to make it the default

By default this script uses "C:\virtualenvs" as the storage path. You can change this with the "-d" argument or edit the variable DEFAULT_DIR_PATH in env.py.

Examples

# List all environments
env.py -l

# Create a new virtual environment
env.py -c mynewvirtualenv

# Delete a virtual environment
env.py -r myoldvirtualenv

# Switch to a new virtual environment
env.py myothervirtualenv

Working within environments

When working within an environment you will not be able to rely on windows to automatically execute python scripts as it will bypass your virtual environment when doing so.

So this:

manage.py runserver

Becomes this:

python manage.py runserver

Issues

If you're developing with the Django development server DO NOT exit it using CTRL-BREAK as instructed. This will bork your command process and you'll have to close it out and open a new window. Use CTRL-C instead.

Updated