Skip to content

Commit b1eb912

Browse files
committed
Added documentation
1 parent 01e122e commit b1eb912

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

docs/html/user_guide.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,49 @@ This is now covered in :doc:`../topics/repeatable-installs`.
782782

783783
This is now covered in :doc:`../topics/dependency-resolution`.
784784

785+
.. _`Managing a different Python interpreter`:
786+
787+
Managing a different Python interpreter
788+
=======================================
789+
790+
Occasionally, you may want to use pip to manage a Python installation other than
791+
the one pip is installed into. In this case, you can use the ``--python`` option
792+
to specify the interpreter you want to manage. This option can take one of three
793+
values:
794+
795+
#. The path to a Python executable.
796+
#. The path to a virtual environment.
797+
#. Either "py" or "python", referring to the currently active Python interpreter.
798+
799+
In all 3 cases, pip will run exactly as if it had been invoked from that Python
800+
environment.
801+
802+
One example of where this might be useful is to manage a virtual environment
803+
that does not have pip installed.
804+
805+
.. tab:: Unix/macOS
806+
807+
.. code-block:: console
808+
809+
$ python -m venv .venv --without-pip
810+
$ python -m pip --python .venv install SomePackage
811+
[...]
812+
Successfully installed SomePackage
813+
814+
.. tab:: Windows
815+
816+
.. code-block:: console
817+
818+
C:\> py -m venv .venv --without-pip
819+
C:\> py -m pip --python .venv install SomePackage
820+
[...]
821+
Successfully installed SomePackage
822+
823+
You could also use ``--python .venv/bin/python`` (or on Windows,
824+
``--python .venv\Scripts\python.exe``) if you wanted to be explicit, but the
825+
virtual environment name is shorter and works exactly the same.
826+
827+
785828
.. _`Using pip from your program`:
786829

787830
Using pip from your program

news/11320.feature.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Add a ``--python`` option to specify the Python environment to be managed by pip.
1+
Add a ``--python`` option to allow pip to manage Python environments other
2+
than the one pip is installed in.

0 commit comments

Comments
 (0)