mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
[doc] Refresh the venv introduction documentation, and correct the statement about VIRTUAL_ENV (GH-98350)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
This commit is contained in:
parent
50553004fe
commit
1a6bacb31f
2 changed files with 79 additions and 90 deletions
|
@ -105,45 +105,3 @@ Multiple paths can be given to ``venv``, in which case an identical virtual
|
|||
environment will be created, according to the given options, at each provided
|
||||
path.
|
||||
|
||||
Once a virtual environment has been created, it can be "activated" using a
|
||||
script in the virtual environment's binary directory. The invocation of the
|
||||
script is platform-specific (`<venv>` must be replaced by the path of the
|
||||
directory containing the virtual environment):
|
||||
|
||||
+-------------+-----------------+-----------------------------------------+
|
||||
| Platform | Shell | Command to activate virtual environment |
|
||||
+=============+=================+=========================================+
|
||||
| POSIX | bash/zsh | $ source <venv>/bin/activate |
|
||||
+-------------+-----------------+-----------------------------------------+
|
||||
| | fish | $ source <venv>/bin/activate.fish |
|
||||
+-------------+-----------------+-----------------------------------------+
|
||||
| | csh/tcsh | $ source <venv>/bin/activate.csh |
|
||||
+-------------+-----------------+-----------------------------------------+
|
||||
| | PowerShell Core | $ <venv>/bin/Activate.ps1 |
|
||||
+-------------+-----------------+-----------------------------------------+
|
||||
| Windows | cmd.exe | C:\\> <venv>\\Scripts\\activate.bat |
|
||||
+-------------+-----------------+-----------------------------------------+
|
||||
| | PowerShell | PS C:\\> <venv>\\Scripts\\Activate.ps1 |
|
||||
+-------------+-----------------+-----------------------------------------+
|
||||
|
||||
When a virtual environment is active, the :envvar:`VIRTUAL_ENV` environment
|
||||
variable is set to the path of the virtual environment. This can be used to
|
||||
check if one is running inside a virtual environment.
|
||||
|
||||
You don't specifically *need* to activate an environment; activation just
|
||||
prepends the virtual environment's binary directory to your path, so that
|
||||
"python" invokes the virtual environment's Python interpreter and you can run
|
||||
installed scripts without having to use their full path. However, all scripts
|
||||
installed in a virtual environment should be runnable without activating it,
|
||||
and run with the virtual environment's Python automatically.
|
||||
|
||||
You can deactivate a virtual environment by typing "deactivate" in your shell.
|
||||
The exact mechanism is platform-specific and is an internal implementation
|
||||
detail (typically a script or shell function will be used).
|
||||
|
||||
.. versionadded:: 3.4
|
||||
``fish`` and ``csh`` activation scripts.
|
||||
|
||||
.. versionadded:: 3.8
|
||||
PowerShell activation scripts installed under POSIX for PowerShell Core
|
||||
support.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue