Skip to main content

VirtEnv

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, system, prompt, bare, virtualenv_py=None)
  • 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.

  • bare, if True, prevents any third-party libraries from being installed. This means you will not have Setuptools, pip, and Wheel available inside the created virtual environment.

  • 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.

Metadata

Release files for virtenv 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for virtenv 0.3.1
File Size Uploaded
virtenv-0.3.1.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for virtenv 0.3.1
File Interpreter ABI Platform
virtenv-0.3.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 10.9 kB

Release files / virtenv-0.3.1.tar.gz

Download URL virtenv-0.3.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9d4a689dade77fa633c533ff695b4267fe5635bde9d29a398bedde6af84d07bf
BLAKE2b-256 checksum
How to use checksums
5a30be38d614c8d2ccc09bf2f500a52c9a8bfb8618a6f3b0f2c774415d5f73c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release files / virtenv-0.3.1-py2.py3-none-any.whl

Download URL virtenv-0.3.1-py2.py3-none-any.whl
Size 5.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
56de8097f3fd7ed35fb50719bc4fd37abafdcd7a244e912e603de03dfa13098b
BLAKE2b-256 checksum
How to use checksums
a9953928da62a36d95c170edbcf8c7773cb107230db40fe6009694d28670db9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page