Python Programming/Getting Python
In order to program in Python you need the Python interpreter. If it is not already installed or if the version you are using is obsolete, you will need to obtain and install Python using the methods below:
Contents |
[edit] Python 2 vs Python 3
In 2008, a new version of Python (version 3) was published that was not entirely backward compatible. Developers were asked to switch to the new version as soon as possible but many of the common external modules are not yet (as of Aug 2010) available for Python 3. There is a program called 2to3 to convert the source code of a Python 2 program to the source code of a Python 3 program. Consider this fact before you start working with Python.
[edit] Installing Python in Windows
Go to the Python Homepage or the ActiveState website and get the proper version for your platform. Download it, read the instructions and get it installed.
In order to run Python from the command line, you will need to have the python directory in your PATH. Alternatively, you could use an Integrated Development Environment (IDE) for Python like DrPython[1], eric[2], PyScripter[3], or Python's own IDLE (which ships with every version of Python since 2.3).
The PATH variable can be modified from the Window's System control panel. The advanced tab will contain the button labelled Environment Variables, where you can append the newly created folder to the search path.
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:\python26
If you downloaded a different version (such as Python 3.1), change the "26" for the version of Python you have (26 is 2.6.x, the current version of Python 2.)
[edit] 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.
[edit] Installing Python on Mac
Users on Apple 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.
[edit] Installing Python on Unix environments
Python is available as a package for some 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.
[edit] Gentoo GNU/Linux
Gentoo is an example of a distribution that installs Python by default - the package system Portage depends on Python.
[edit] Ubuntu GNU/Linux
Users of Ubuntu will notice that Python comes installed by default, only it sometimes is not the latest version. If you would like to update it, click here.
[edit] Arch GNU/Linux
Arch does not install python by default, but is easily available for installation through the package manager to pacman. As root (or using sudo if you've installed and configured it), type:
$ pacman -Sy python
This will be update package databases and install python. Other versions can be built from source from the Arch User Repository.
[edit] 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.
[edit] Other Distributions
There are other Python distributions as well.These distributions are basked on the standard implementation of Python, written in C Programming. But then there are others which take different approach. For Example: Jython & Iron Python. If you somehow, seem to be interested in some other development environment other than IDLE, well here are some options:
Some Integrated Development Environments (IDEs) for Python
| Environment | Description | Get From |
|---|---|---|
| Pythonwin | Windows Oriented Environment | Pythonwin |
| ActivePython | Highly Flexible, Pythonwin IDE | ActivePython |
| Komodo | A Commercial IDE | Komodo |
| Anjuta | IDE Linux/Unix | Anjuta |
| BlackAdder | Commercial IDE & GUI Builder | BlackAdder |
| Code Crusader | Commercial IDE | Code Crusader |
| Code Forge | Commercial IDE | Code Forge |
| KDevelop | Cross Language IDE for KDE | KDevelop |
| VisualWx | Free GUI Builder | VisualWx |
| Eclipse | Open Source IDE | Eclipse |
| Jython | Java Version of Python | Jython |
| IronPython | C# Version of Python | IronPython |
[edit] Keeping Up to Date
Python has a very active community and language itself evolves continuously. Do frequently visit Python.Org for recent releases and relevant tools. The website is an invaluable asset.
If you want to keep up with newly released third party-modules or software for Python, have a look at Python email list python-announce-list. General discussion can be found at python-list, both of these lists can be found at Python Mail. Usenet users can easily user the newsgroups comp.lang.python.announce & comp.lang.python.