Skip to content

Commit 5c0d4c2

Browse files
[3.11] gh-88452: Add a warning about non-portability of environments. (GH-98155) (GH-98157)
1 parent 1269297 commit 5c0d4c2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Doc/library/venv.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ Creating virtual environments
8585
without there needing to be any reference to its virtual environment in
8686
``PATH``.
8787

88+
.. warning:: Because scripts installed in environments should not expect the
89+
environment to be activated, their shebang lines contain the absolute paths
90+
to their environment's interpreters. Because of this, environments are
91+
inherently non-portable, in the general case. You should always have a
92+
simple means of recreating an environment (for example, if you have a
93+
requirements file ``requirements.txt``, you can invoke ``pip install -r
94+
requirements.txt`` using the environment's ``pip`` to install all of the
95+
packages needed by the environment). If for any reason you need to move the
96+
environment to a new location, you should recreate it at the desired
97+
location and delete the one at the old location. If you move an environment
98+
because you moved a parent directory of it, you should recreate the
99+
environment in its new location. Otherwise, software installed into the
100+
environment may not work as expected.
88101

89102
.. _venv-api:
90103

0 commit comments

Comments
 (0)