NAME
virtualenvwrapper - a set of wrappers to assist with manage your python virtualenvsMANAGING ENVIRONMENTS
mkvirtualenv
Create a new environment, in the WORKON_HOME.mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] ENVNAME
$ workon $ mkvirtualenv mynewenv New python executable in mynewenv/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. (mynewenv)$ workon mynewenv (mynewenv)$
- •
- scripts-premkvirtualenv
- •
- scripts-postmkvirtualenv
- •
- requirements file format
mktmpenv
Create a new virtualenv in the WORKON_HOME directory.mktmpenv [(-c|--cd)|(-n|--no-cd)] [VIRTUALENV_OPTIONS]
$ mktmpenv Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7' New python executable in 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/bin/python Overwriting 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/lib/python2.7/distutils/__init__.py with new content Installing setuptools............................................... .................................................................... .................................................................done. This is a temporary environment. It will be deleted when deactivated. (1e513ac6-616e-4d56-9aa5-9d0a3b305e20) $
lsvirtualenv
List all of the environments.lsvirtualenv [-b] [-l] [-h]
- -b
- Brief mode, disables verbose output.
- -l
- Long mode, enables verbose output. Default.
- -h
- Print the help for lsvirtualenv.
- •
- scripts-get_env_details
showvirtualenv
Show the details for a single virtualenv.showvirtualenv [env]
- •
- scripts-get_env_details
rmvirtualenv
Remove an environment, in the WORKON_HOME.rmvirtualenv ENVNAME
(mynewenv)$ deactivate $ rmvirtualenv mynewenv $ workon $
- •
- scripts-prermvirtualenv
- •
- scripts-postrmvirtualenv
cpvirtualenv
Duplicate an existing virtualenv environment. The source can be an environment managed by virtualenvwrapper or an external environment created elsewhere.Copying virtual environments is not well
supported. Each virtualenv has path information hard-coded into it, and there
may be cases where the copy code does not know it needs to update a particular
file. Use with caution.
cpvirtualenv ENVNAME [TARGETENVNAME]
Target environment name is required for
WORKON_HOME duplications. However, target environment name can be ommited for
importing external environments. If omitted, the new environment is given the
same name as the original.
$ workon $ mkvirtualenv source New python executable in source/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. (source)$ cpvirtualenv source dest Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install relative Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install-2.6 relative Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/pip relative Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postdeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/preactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/predeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) (dest)$ workon dest source (dest)$
- •
- scripts-precpvirtualenv
- •
- scripts-postcpvirtualenv
- •
- scripts-premkvirtualenv
- •
- scripts-postmkvirtualenv
allvirtualenv
Run a command in all virtualenvs under WORKON_HOME.allvirtualenv command with arguments
$ allvirtualenv pip install -U pip
CONTROLLING THE ACTIVE ENVIRONMENT
workon
List or change working virtual environmentsworkon [(-c|--cd)|(-n|--no-cd)] [environment_name|"."]
$ workon $ mkvirtualenv env1 New python executable in env1/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. (env1)$ mkvirtualenv env2 New python executable in env2/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. (env2)$ workon env1 env2 (env2)$ workon env1 (env1)$ echo $VIRTUAL_ENV /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 (env1)$ workon env2 (env2)$ echo $VIRTUAL_ENV /Users/dhellmann/Devel/virtualenvwrapper/tmp/env2 (env2)$
- •
- scripts-predeactivate
- •
- scripts-postdeactivate
- •
- scripts-preactivate
- •
- scripts-postactivate
- •
- variable-VIRTUALENVWRAPPER_WORKON_CD
deactivate
Switch from a virtual environment to the system-installed version of Python.deactivate
This command is actually part of virtualenv,
but is wrapped to provide before and after hooks, just as workon does for
activate.
$ workon $ echo $VIRTUAL_ENV $ mkvirtualenv env1 New python executable in env1/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. (env1)$ echo $VIRTUAL_ENV /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 (env1)$ deactivate $ echo $VIRTUAL_ENV $
- •
- scripts-predeactivate
- •
- scripts-postdeactivate
QUICKLY NAVIGATING TO A VIRTUALENV
There are two functions to provide shortcuts to navigate into the currently-active virtualenv.cdvirtualenv
Change the current working directory to $VIRTUAL_ENV.cdvirtualenv [subdir]
$ mkvirtualenv env1 New python executable in env1/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. (env1)$ echo $VIRTUAL_ENV /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 (env1)$ cdvirtualenv (env1)$ pwd /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 (env1)$ cdvirtualenv bin (env1)$ pwd /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/bin
cdsitepackages
Change the current working directory to the site-packages for $VIRTUAL_ENV.cdsitepackages [subdir]
$ mkvirtualenv env1 New python executable in env1/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. (env1)$ echo $VIRTUAL_ENV /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 (env1)$ cdsitepackages PyMOTW/bisect/ (env1)$ pwd /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/lib/python2.6/site-packages/PyMOTW/bisect
lssitepackages
Calling lssitepackages shows the content of the site-packages directory of the currently-active virtualenv.lssitepackages
$ mkvirtualenv env1 New python executable in env1/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. (env1)$ $ workon env1 (env1)$ lssitepackages setuptools-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg easy-install.pth setuptools.pth
PATH MANAGEMENT
add2virtualenv
Adds the specified directories to the Python path for the currently-active virtualenv.add2virtualenv directory1 directory2 ...
- 1.
- Check out the source for a big project, such as Django.
- 2.
- Run: add2virtualenv path_to_source.
- 3.
- Run: add2virtualenv.
- 4.
- A usage message and list of current "extra" paths is printed.
- 5.
- Use option -d to remove the added path.
toggleglobalsitepackages
Controls whether the active virtualenv will access the packages in the global Python site-packages directory.toggleglobalsitepackages [-q]
$ mkvirtualenv env1 New python executable in env1/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. (env1)$ toggleglobalsitepackages Disabled global site-packages (env1)$ toggleglobalsitepackages Enabled global site-packages (env1)$ toggleglobalsitepackages -q (env1)$
PROJECT DIRECTORY MANAGEMENT
SEE ALSO:project-management
mkproject
Create a new virtualenv in the WORKON_HOME and project directory in PROJECT_HOME.mkproject [-f|--force] [-t template] [virtualenv_options] ENVNAME
- -f, --force
- Create the virtualenv even if the project directory already exists
$ mkproject myproj New python executable in myproj/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. Creating /Users/dhellmann/Devel/myproj (myproj)$ pwd /Users/dhellmann/Devel/myproj (myproj)$ echo $VIRTUAL_ENV /Users/dhellmann/Envs/myproj (myproj)$
- •
- scripts-premkproject
- •
- scripts-postmkproject
setvirtualenvproject
Bind an existing virtualenv to an existing project.setvirtualenvproject [virtualenv_path project_path]
$ mkproject myproj New python executable in myproj/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. Creating /Users/dhellmann/Devel/myproj (myproj)$ mkvirtualenv myproj_new_libs New python executable in myproj/bin/python Installing setuptools............................................. .................................................................. .................................................................. done. Creating /Users/dhellmann/Devel/myproj (myproj_new_libs)$ setvirtualenvproject $VIRTUAL_ENV $(pwd)
cdproject
Change the current working directory to the one specified as the project directory for the active virtualenv.cdproject
MANAGING INSTALLED PACKAGES
wipeenv
Remove all of the installed third-party packages in the current virtualenv.wipeenv
OTHER COMMANDS
virtualenvwrapper
Print a list of commands and their descriptions as basic help output.virtualenvwrapper
COPYRIGHT
2009-2019, Doug HellmannSeptember 3, 2019 | 4.8.4 |