Python
From What is Python?:
- Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high level dynamic data types, and classes. It supports multiple programming paradigms beyond object-oriented programming, such as procedural and functional programming. Python combines remarkable power with very clear syntax. It has interfaces to many system calls and libraries, as well as to various window systems, and is extensible in C or C++. It is also usable as an extension language for applications that need a programmable interface. Finally, Python is portable: it runs on many Unix variants including Linux and macOS, and on Windows.
Installation
Install the python package, which provides the current release of Python 3.
Other versions
Previous and future versions of Python are available via the AUR, and may be useful for old applications that do not run on the current version, for programs intended to run on other versions, or just for curiosity:
- Python 3.11: python311AUR
- Python 3.10: Current release, see previous section
- Python 3.9:
- Python 3.8:
- Python 3.7:
- Python 3.6: (unmaintained)
- Python 2.7: (unmaintained)
Each of these packages installs a distinct binary named after the version number, e.g. python3.7 for Python 3.7, allowing multiple versions to coexist on a system. You can also use pyenv to easily switch between multiple versions of Python.
Extra modules/libraries for old versions of Python may be found on the AUR by searching for python<version without period>
, e.g. searching for for Python 3.7 modules.
You can also download the source for any release on the https://www.python.org/downloads/ page.
Alternative implementations
The python package installs CPython, the reference implementation of Python. However, there are also other implementations available. These implementations are usually based on older versions of Python and are not fully compatible with CPython.
Implementations available on Arch Linux include:
More implementations exist. Some, such as Stackless, Pyston and Cinder are used internally at large technology companies. Others are historically notable but are no longer maintained due to improvements in the most popular implementations.
Alternative shells
The python package includes an interactive Python shell/REPL which can be launched with the command. The following shells are also available:
- ptpython — An advanced Python REPL built with prompt-toolkit.
Package management
There are several ways to install Python packages on Arch Linux:
- Official repositories and AUR — A large number of popular packages are available in the Arch repositories. This is the preferred way to install system-wide packages.
- pip(1) — The official package installer for Python. You can use pip to install packages from the Python Package Index and other indexes.
When installing packages using pip, it is recommended to use a virtual environment to prevent conflicts with system packages in . Alternatively, can be used to install packages into the user scheme instead of . pipx and Conda integrate environment management into their workflows.
See the Python Packaging User Guide for the official best practices for package management.
Historically, easy_install (part of ) was used to install packages distributed as Eggs. easy_install and Eggs have been replaced with pip and Wheels. See pip vs easy_install and Wheel vs Egg for more information.
Widget bindings
The following widget toolkit bindings are available:
- Qt for Python (PySide2) — The official Python bindings for Qt5.
- pyQt — A set of Python bindings for Qt.
To use these with Python, you may also need to install the associated widget toolkit packages (e.g. must also be installed to use Tkinter).
Tips and tricks
Virtual environment
Python provides tools to create isolated virtual environments into which packages may be installed without conflicting with other virtual environments or the system packages. Virtual environments can also run applications with different versions of Python on the same system.
See Python/Virtual environment for details.
Tab completion in Python shell
Tab completion is available in the interactive shell by default. Note that the readline completer will only complete names in the global namespace. You can use for a richer tab completion experience .
See also
Official
- Official Python documentation (Can be installed with the package for offline access.)
- Official Python tutorial
Third-Party
- Automate the Boring Stuff with Python - Creative Commons book
- Awesome Python - A curated list of Python resources
- A Byte of Python - Creative Commons book
- Cracking Codes With Python - Free online book
- Crash into Python - Free tutorial
- Debugging in Python - Guide to using , the Python debugger
- Dive Into Python - Creative Commons book
- Fluent Python - Commercial book
- Introducing Python - Commercial book
- Invent Your Own Computer Games with Python - Free online book
- Learn Python - Free interactive tutorial
- Learn Python the Hard Way - Commercial book
- Pythonspot Python Tutorials - Free online tutorials
- Think Python - Creative Commons book