# Python Programming/Getting Python


To program in Python, you need a Python interpreter to run your
code---we will discuss interpreters later. If it\'s not already
installed, or if the version you are using is obsolete, you will need to
obtain and install Python using the methods below. The current Python
versions are 3.x; versions 2.x are discontinued and no longer
maintained.

## Installing Python in Windows

Go to the Python Homepage and get the
proper version for your platform. Download it, read the instructions and
get it installed.

To run Python from the command line, you will need to have the python
directory in your PATH. You can instruct the Python installer to add
Python to the path, but if you do not do that, you can add it manually.
The PATH variable can be modified from the Window\'s System control
panel. To expand the PATH in Windows 7:

1.  Go to Start.
2.  Right click on computer.
3.  Click on properties.
4.  Click on \'Advanced System Settings\'
5.  Click on \'Environmental Variables\'.
6.  In the system variables select Path and edit it, by appending a
    \';\' (without quote) and adding \'C:\\python27\'(without quote).

If you prefer having a temporary environment, you can create a new
command prompt short-cut that automatically executes the following
statement:

`PATH %PATH%;c:\python27`

If you downloaded a different version (such as Python 3.1), change the
\"27\" for the version of Python you have (27 is 2.7.x, the current
version of Python 2.)

### Cygwin

By default, the Cygwin installer for Windows does not include Python in
the downloads. However, it can be selected from the list of packages.

## Installing Python on Mac

Users on Mac OS X will find that it already ships with Python 2.3 (OS X
10.4 Tiger) or Python 2.6.1 (OS X Snow Leopard), but if you want the
more recent version head to Python Download
Page follow the instruction on the
page and in the installers. As a bonus you will also install the Python
IDE.

## Installing Python on Unix environments

Python is available as a package for most Linux distributions. In some
cases, the distribution CD will contain the python package for
installation, while other distributions require downloading the source
code and using the compilation scripts.

### Gentoo Linux

Gentoo includes Python by default---the package management system
*Portage* depends on Python.

### Ubuntu Linux

Users of Ubuntu will notice that Python comes installed by default, only
it sometimes is not the latest version. To check which version of Python
is installed, type

``` bash
python -V
```

into the terminal.

### Arch Linux

Arch Linux does not come with Python pre-installed by default, but it is
easily available for installation through the package manager to pacman.
As root (or using sudo if you\'ve installed and configured it), type:

``` bash
pacman -S python
```

This will be update package databases and install Python 3. Python 2 can
be installed with:

``` bash
pacman -S python2
```

Other versions can be built from source from the Arch User Repository.

### Source code installations

Some platforms do not have a version of Python installed, and do not
have pre-compiled binaries. In these cases, you will need to download
the source code from the official
site. Once the download is complete,
you will need to unpack the compressed archive into a folder.

To build Python, simply run the configure script (requires the Bash
shell) and compile using make.

### Other Distributions

Python, also referred to as CPython to avoid confusion, is written in
the C programming
language "wikilink"), and is the
official reference implementation. CPython can run on various platforms
due to its portability.

Apart from CPython there are also other implementations that run on top
of a virtual machine. For example, on Java\'s JRE (Java Runtime
Environment) or Microsoft\'s .NET CLR (Common Language Runtime). Both
can access and use the libraries available on their platform.
Specifically, they make use of
reflection "wikilink") that allows
complete inspection and use of all classes and objects for their very
technology.

*Python Implementations (Platforms)*

  Environment   Description              Get From
  ------------- ------------------------ -----------------------------------------
  Jython        Java Version of Python   Jython
  IronPython    C# Version of Python     IronPython

### Integrated Development Environments (IDE)

It\'s common to use a simple text editor for writing Python code, but
you may feel the need to upgrade to a more advanced *IDE*. CPython ships
with IDLE; however, IDLE is not considered user-friendly.[^1] For Linux,
KDevelop and Spyder are popular. For Windows, PyScripter is free, quick
to install, and comes included with
PortablePython.

*Some Integrated Development Environments (IDEs) for Python*

  Environment              Description                               Get From
  ------------------------ ----------------------------------------- ----------------------------------------------------
  ActivePython             Highly flexible, Pythonwin IDE            ActivePython
  Anjuta                   IDE Linux/Unix                            Anjuta
  Eclipse (PyDev plugin)   Open-source IDE                           Eclipse
  Eric                     Open-source Linux/Windows IDE.            Eric
  KDevelop                 Cross-language IDE for KDE                KDevelop
  Ninja-IDE                Cross-platform open-source IDE.           Nina-IDE
  PyScripter               Free Windows IDE (portable)               PyScripter
  Pythonwin                Windows-oriented environment              Pythonwin
  Spyder                   Free cross-platform IDE (math-oriented)   Spyder
  VisualWx                 Free GUI Builder                          VisualWx

The Python official wiki has a complete list of
IDEs.

There are several commercial IDEs such as Komodo, BlackAdder, Code
Crusader, Code Forge, and PyCharm. However, for beginners learning to
program, purchasing a commercial IDE is unnecessary.

## Trying Python online

You can try Python online, thereby avoiding the need to install. The
online Python shell at Python\'s
official site provides a web Python REPL (read--eval--print loop).

## Keeping Up to Date

Python has a very active community and the language itself is evolving
continuously. Make sure to check python.org for
recent releases and relevant tools. The website is an invaluable asset.

Public Python-related mailing lists are hosted at
mail.python.org. Two examples of such mailing
lists are the **Python-announce-list** to keep up with newly released
third party-modules or software for Python and the general discussion
list **Python-list**. These lists are mirrored to the Usenet newsgroups
**comp.lang.python.announce** & **comp.lang.python**.

## Notes


[^1]: The Things I Hate About IDLE That I Wish Someone Would
    Fix.
