# pydoc > virtualenv

---
type: CommandReference
command: virtualenv
mode: pydoc
section: 
source: pydoc3
---

## Quick Reference
- `virtualenv.cli_run(['myenv'])` — Create a virtual environment named `myenv`
- `virtualenv.session_via_cli(['myenv'])` — Inspect what a virtual environment would look like, without creating it
- `virtualenv.__version__` — Get the installed virtualenv version

## Name
virtualenv — Create isolated Python environments

## Synopsis
python
virtualenv.cli_run(args, options=None, setup_logging=True, env=None)
virtualenv.session_via_cli(args, options=None, setup_logging=True, env=None)
## Parameters
Both functions accept the same set of parameters:

- `args` — Command line arguments as a list of strings (e.g., `['venv']`)
- `options` — Optional `VirtualEnvOptions` object to capture parsed options; if `None`, options are parsed internally
- `setup_logging` — `True` to set up logging handlers automatically; `False` to use already registered handlers
- `env` — Dictionary of environment variables to use; if `None`, the current OS environment is used

## Functions
- `cli_run()` — Create a virtual environment given CLI arguments. Returns the session object (experimental structure).
- `session_via_cli()` — Same as `cli_run()` but does not perform the actual creation; returns the session object for inspection only.

## Examples
python
import virtualenv

# Create a virtual environment in the directory 'myenv'
session = virtualenv.cli_run(['myenv'])

# Examine what a virtual environment would look like without creating it
session_info = virtualenv.session_via_cli(['myenv'])

# Print the version
print(virtualenv.__version__)
## See Also
- [venv](https://docs.python.org/3/library/venv.html) — The built‑in virtual environment module
- [virtualenv command line](https://virtualenv.pypa.io/) — The shell command for creating virtual environments
- `python -m pip install virtualenv` — Install the package

## Exit Codes
Not documented.