# How to Create A New VENV in Python ( Virtual Environment )

Every online reality does have its own Python binary (which must match the edition of the binary used to create it) and a collection of Modules.installed in its site folders.

For additional information on Python virtual environments, see PEP 405.

Contents

## How to Create A New VENV in Python

### Developing virtual worlds

The command venv:create virtual environment use to create virtual environments.

venv /path/to/new/virtual/environment python3 -m

Running this command produces a pyvenv.cfg file in the target directory (along with any parent directories that don’t already exist) and a home key pointing to the Python installation from which the command performs (a common name for the target directory is .venv).

It also makes a copy/symlink of the Python binary/binaries in the bin (or Scripts on Windows) subdirectory (as appropriate for the platform or arguments used at environment creation time).

This even creates a subdirectory called lib/pythonX, which is initially empty. site-packages/Y/(on Windows, this is Lib\site-packages). It will be re-used if you specify an existing directory.

pyvenv was the recommended tool for building virtual environments in Python 3.3 and 3.4, but it has been deprecated since Python 3.6.

In version 3.5, it is now suggested to use venv to create virtual environments.

### To use the venv command on Windows, type:

c:>python -m venv c:Python35 c:\path\to\myenv

Alternatively, if your Python installation’s PATH and PATHEXT variables were set correctly:

c:>venv python -m c:\path\to\myenv

If you execute the command with -h, it will display you the available options:

venv is a word that uses a lot. [-h] [—system-site-packages] —copies | —symlinks [—clear]

[—upgrade] [—without-pip] [—PROMPT] [—upgrade-deps]

[ENV DIR...] ENV DIR [ENV DIR...]



In one or more target folders, create virtual Python environments.

ENV DIR is a positional argument. A directory in which the environment will create.

system-site-packages

• copies Even if symlinks are the platform’s default, try to use copies rather than symlinks.
• clear Before creating an environment, delete the contents of the environment directory if it already exists.
• without-pip Pip is not installed or upgraded in the virtual environment (bootstrap default)
• This environment’s alternative prompt prefix provides —prompt PROMPT.
• You may desire to activate an environment after it has for example, by locating an activate script in its bin directory.
• In version 3.9, the following change:

Changed in version 3.4: Pip is now installed by default, and the —without-pip and —copies options have.

Previously, if the destination directory already existed, an error unless the —clear or —upgrade option. This is in version 3.4.

### Note Although Windows supports symlinks, they are not encouraged

Note On Microsoft Windows, the Activate.ps1 script may need to change the user’s execution policy. This can complete with the following PowerShell command:

C:> PS Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

### For further information, see About Execution Policies

Ensurepip will use to bootstrap pip into the virtual environment unless the —without-pip option.

Multiple routes can to venv, in which case each path will generate an identical virtual environment based on the choices provided.

Tags: