Skip to content

Commit fb2ba1c

Browse files
docs: Recommend specific python version for virtualenv (#2916)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5c6ef7b commit fb2ba1c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

docs/changelog/2808.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add a note to the user guide recommending the use of a specific Python version when creating virtual environments.
2+
Contributed by :user:`esafak`.

docs/user_guide.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ Virtualenv has one basic command:
3030
3131
virtualenv venv
3232
33+
.. note::
34+
35+
When creating a virtual environment, it's recommended to use a specific Python version, for example, by invoking
36+
virtualenv with ``python3.10 -m virtualenv venv``. If you use a generic command like ``python3 -m virtualenv venv``,
37+
the created environment will be linked to ``/usr/bin/python3``. This can be problematic because when a new Python
38+
version is installed on the system, the ``/usr/bin/python3`` symlink will likely be updated to point to the new
39+
version. This will cause the virtual environment to inadvertently use the new Python version, which is often not the
40+
desired behavior. Using a specific version ensures that the virtual environment is tied to that exact version,
41+
providing stability and predictability.
42+
3343
This will create a python virtual environment of the same version as virtualenv, installed into the subdirectory
3444
``venv``. The command line tool has quite a few of flags that modify the tool's behavior, for a
3545
full list make sure to check out :ref:`cli_flags`.

0 commit comments

Comments
 (0)