Python

Python is the language that powers Portage, eselect, equery, and other tools in Gentoo.

Installation
Since Python is so integral to Gentoo there is little chance it is not installed. Doing so would be like removing the heart from Gentoo. There is occasion where Python must be recompiled in order to add new features or to upgrade.

Emerge
Python is slotted, which means there is more than one version Python that can be installed on a Gentoo system at the same time. Select the version to install by using an  (colon) and the package atom followed by one of the slot numbers:

For example, to install Python 3.4:

Setting the active interpreter
The active Python interpreter can be set using the command. First list the available interpreters using :

Select the desired interpreter using. In this example the second option was chosen:

Version upgrade
The old  is no longer used.

Before you start, ensure that your system is uptodate:

Then, update Python if you hadn't done so already:

In order to tell your system to use the new Python version, update the variables  and , for instance in your   (when updating from 3.4 to 3.5):
 * PYTHON_TARGETS="python2_7 python3_5"
 * PYTHON_SINGLE_TARGET="python3_5"

and run

again. You may be asked to update any remaining  USE flags as well.

Once your upgrade has completed, you should be able to remove the old Python version using

Invocation
A specific version of the Python interpreter can be invoked from the command-line directly by running:

Or

To execute a script with Python 2.x use the following header: