Python

From Gentoo Wiki
Jump to: navigation, search
This article is a stub. You can help by expanding it.

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.

USE flags

USE flags for dev-lang/python An interpreted, interactive, object-oriented programming language

build !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used for creating build images and the first half of bootstrapping [make stage1] global
examples Install examples, usually source code global
gdbm Add support for sys-libs/gdbm (GNU database libraries) global
hardened Activate default security enhancements for toolchain (gcc, glibc, binutils) global
ipv6 Add support for IP version 6 global
libressl Use dev-libs/libressl as SSL provider (might need ssl USE flag), packages should not depend on this USE flag global
ncurses Add ncurses support (console display library) global
readline Enable support for libreadline, a GNU line-editing library that almost everyone wants global
sqlite Add support for sqlite - embedded sql database global
ssl Add support for Secure Socket Layer connections global
threads Enable threading support. (DON'T DISABLE THIS UNLESS YOU KNOW WHAT YOU'RE DOING) local
tk Add support for Tk GUI toolkit global
wininst Install Windows executables required to create an executable installer for MS Windows. local
xml Add support for XML files global

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:

root #emerge --ask dev-lang/python:3.4

Configuration

Setting the active interpreter

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

root #eselect python list

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

root #eselect python set 2

Usage

Invocation

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

user $python2.7

Or

user $python3.4

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

FILE /usr/local/bin/repo
#!/usr/bin/env python2
...

See also

  • Bash - The original Linux scripting language.
  • Pip - Python's built-in package management system.