Skip to main content

Create a virtual environment with venv or virtualenv

Project description

A simple script to encapsulate venv and virtualenv creation in one. venv is always used if possible; if it’s not, virtualenv will be used (if specified) as the fallback option.

This file can be used either as a standalone script, or a module to import.

Python API

create(python, env_dir, virtualenv_py, system, prompt)
  • python should be an absolute path pointing to a Python executable. If this is not None, and does not match sys.executable, that interpreter is launched as a subprocess to run this script. Otherwise, the creation is done in-process (subprocesses may still be run in steps during the creation).

  • env_dir points to the directory to create the new virtual environment.

  • system specifies whether system site packages will be available for the created virtual environment.

  • prompt specifies the prompt prefix used in the created virtual environment’s activate scripts.

  • virtualenv_py should be an absolute path pointing to a virtualenv.py script. This is optional; if missing, virtualenv will not be used to create a virtual environment.

Command line API

virtenv env_dir --python PYTHON [--system] [--prompt PROMPT]

Meanings of arguments are similar to the Python API.

The python argument is required, and can be a version, such as 3.7. A suitable Python executable will be looked up automatically if possible.

When is venv used

As mentioned above, venv is always preferred if possible. virtualenv is used for the following scenarios:

  • When the module venv is not available in the target Python.

  • When the module ensurepip is not available in the target Python. This generally happens for Python 3.3, or distributions such as Debian that don’t like to bundle ensurepip. Without it, pip wouldn’t be available, and we don’t want that.

  • When sys.real_prefix is set. This usually means the target Python is managed by a virtualenv, and venv is known to have problems working in this situation. See discussion in bpo-30811 and pypa/virtualenv#1095 for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

virtenv-0.2.6.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

virtenv-0.2.6-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file virtenv-0.2.6.tar.gz.

File metadata

  • Download URL: virtenv-0.2.6.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for virtenv-0.2.6.tar.gz
Algorithm Hash digest
SHA256 72438357136047b1a738d79263d15d366ec5908297d466eabd593dfdca2c0378
MD5 16d6764b0b4fa4d38bb8a9d9426c45a1
BLAKE2b-256 5e6286966989badbca112ffe9ca3278c99c14744a03f4d6c194a36a13a911e28

See more details on using hashes here.

File details

Details for the file virtenv-0.2.6-py2.py3-none-any.whl.

File metadata

  • Download URL: virtenv-0.2.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for virtenv-0.2.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 618e5e3eaab6b2ca40b35f14b65a32ae9705c9d1cf6af937dfba6f0f174c7db2
MD5 9af482490d0bec4ad5792fb0b2b58ebf
BLAKE2b-256 080079d8aabf1e8bee593d92308a8109428c054d9b8f8147c503f23c0cb36cbb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page