Python¶
The primary interface to virtualenv is the command line application. However, it can also be used programmatically
via the virtualenv.cli_run function and the Session class.
See Use virtualenv for usage examples.
virtualenv module¶
- virtualenv.cli_run(args, options=None, setup_logging=True, env=None)¶
Create a virtual environment given some command line interface arguments.
- Parameters:
options (
VirtualEnvOptions|None) – passing in aVirtualEnvOptionsobject allows return of the parsed optionssetup_logging (
bool) –Trueif setup logging handlers,Falseto use handlers already registeredenv (
MutableMapping[str,str] |None) – environment variables to use
- Return type:
- Returns:
the session object of the creation (its structure for now is experimental and might change on short notice)
- virtualenv.session_via_cli(args, options=None, setup_logging=True, env=None)¶
Create a virtualenv session (same as cli_run, but this does not perform the creation). Use this if you just want to query what the virtual environment would look like, but not actually create it.
- Parameters:
options (
VirtualEnvOptions|None) – passing in aVirtualEnvOptionsobject allows return of the parsed optionssetup_logging (
bool) –Trueif setup logging handlers,Falseto use handlers already registeredenv (
MutableMapping[str,str] |None) – environment variables to use
- Return type:
- Returns:
the session object of the creation (its structure for now is experimental and might change on short notice)
Session class¶
The Session class represents a virtualenv creation session and provides access to the created environment’s
properties.
- class virtualenv.run.session.Session(verbosity, app_data, interpreter, creator, seeder, activators)¶
Represents a virtual environment creation session.
- Parameters:
- property interpreter: PythonInfo¶
Create a virtual environment based on this reference interpreter.
VirtualEnvOptions¶
Options namespace passed to plugin constructors, populated from the CLI, environment variables, and configuration files.