@@ -782,6 +782,49 @@ This is now covered in :doc:`../topics/repeatable-installs`.
782
782
783
783
This is now covered in :doc: `../topics/dependency-resolution `.
784
784
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
+
785
828
.. _`Using pip from your program` :
786
829
787
830
Using pip from your program
0 commit comments