Skip to content

Commit bf6b52e

Browse files
[3.10] gh-88452: Add a warning about non-portability of environments. (GH-98155) (GH-98156)
1 parent 64ce2cb commit bf6b52e

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
@@ -84,6 +84,19 @@ Creating virtual environments
8484
without there needing to be any reference to its virtual environment in
8585
``PATH``.
8686

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

88101
.. _venv-api:
89102

0 commit comments

Comments
 (0)