• programming in python • a course for the curious •

Installation instructions


Which version to choose? The basic choice is between a version higher than 3.0 or not. This course is focusing on Python 2 series and there are number of reasons to do that. The best choice is then is to install the Python 2.7 which will is (and will be) the last version of the Python 2.x series. It has some features of Python 3. Python 3 changes the language considerably, simplifies it in many places making it easier to work with. Though still many Python modules are not yet ported to Python 3 and hence many programs are still being written using the Python 2.x series. After all the essential basics of Python2 and Python3 are the same (it is still Python). This lecture is written in the way to make it easy to learn (and understand) Python 3 features. If you choose to install Python3 version install the version 3.3 at least. But the best is to install both Python2.7 and Python3.3 (or higher). We will also focus on differences and how to code so that the version does not matter.

In the following sections we show how to obtain Python from its original source. But there are also other sources where you can get Python. For example ActivePython or Enthought . Both can be downloaded for Windows, MaxOs or Linux. ActivePython comes with a package manager for Python modules. However installation and management of additional modules in Python is very easy.

Check the md5sum

After downloading you should check the md5sum. It is will assure you that you have installed the original Python which has not been modified (i.e. it is free of viruses and nasty things). The md5sum is a number which can be counted for any file, and it does solely depend on the file, not on the machine that was computing it. If a file was modified then its md5sum will be different. At the above url you have md5sum sum of the Python installer. What you need to do is to calculate the md5sum on your computer and compare it with the one that has been published. If they match its fine, you can go on. If they not better be careful, since the file was changed after it was posted. On Windows you can use this program, written by Jem Berkes, to compute md5sum: md5sum , on MacOs you can use the openssh which is by default installed. Just open the Terminal application an write:

openssl md5 file

Where file is path to the downloaded file (you can use the cd command to switch the directories and ls to list them). On linux you can use md5sum. Open a terminal (Gnome Terminal in Gnome, Konsole in Ubuntu, or just an xterm) and type:

md5sum file

After that you will get a number like this one 2ab3e47203d57a6f8ff95f56038c4ebc which you have to compare to the one published at the www.python.org web page.

Installation on Windows

You have to download the Windows installer from here. There is a web page dedicated to the 2.7.3 release: here, and a similar page for Python 3.3. Then you can check its md5sum and run it. After installation you might need to set PATH environment variable so that python.exe (and pythonw.exe) will be accessible. The wizard to change the environment variables is in:

System ‣ Advanced system settings ‣ Advanced ‣ Environment Variables

To get the System wizard right click the Computer and go to Properties, or open the Control Panel, then under System and Security you will find the System wizard. You might want to look up here for further information if needed.

Installation on MacOs

On MacOs there is a pre-installed version of python, but it might be a bit old. You can check it out: run the Terminal application (it is under Applications/Utilities and type


After pressing Enter you should see something like this:

Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license"
for more information.

To get back to the command prompt press CTRL+d or write exit() and press Enter. You can download the MacOs installer from here, checkout its md5sum and run it.

You should also read this document. It explains some important installation details and also some good advices how to start using Python on MacOs.

Installation on Linux

On Linux Python is usually installed together with a system. If not, use your distribution tools to install it. In this way you will get updates. On some Linux distributions you may install several versions of Python (for example one from 2.x and another from 3.x series). To check it out (on Ubuntu which comes with Gnome):

Applications ‣ Accessories ‣ Terminal

And type python To exit press CTRL+d or type exit() and press Enter.

If your system comes with KDE enviroment use Konsole instead of the Gnome Terminal.

Installation from sources

You can also download the sources of Python and compile it by yourself. This is not too difficult, but it requires some work. First you need to have installed C interpreter and all the necessary libraries that are needed to compile Python. The sources of Python 2.7.3 are available here and the sources of Python 3.3.0 can be found here. If you want to install from sources this guide might be very helpful.

Setup tools and pip

You may want to install setup tools for python. They contain the easy_install program which you can use to install additional Python modules. Python comes with a large amount of modules, but sometimes this is not enough. We will use easy_install in the next section to install IPython. On Linux you just have to install the easyinstall package maintained by your distribution. On Windows and MacOs just follow the instructions at https://pypi.python.org/pypi/setuptools. At some point it is good to familiarise oneself with the documentation. On Windows this will install easy_install.exe under the directory C:/Python27/Scripts (assuming that Python has been installed under C:/Python27). You should add it to the PATH environment variable. This will make your life easier later on.

Even on Linux easy_install is useful: though many Python packages are maintained by distributions some of them are not. You may use it also to obtain a more recent version. If this is the case note that by default easy_install will install modules under /usr/lib/python2.7 (or /usr/lib/python3.3 depending on the version you use), i.e. where your system installs them. This is not a good place since if you have a copy from your Linux distribution, next time you update the system it may be overwritten. Also it will be difficult for you to check which Python modules you maintain yourself. You can pass --prefix=$HOME/.local argument to install modules under $HOME/.local/lib. You will need to make the directory $HOME/.local/lib/python3.3/site-packages and set the environment variable PYTHOPATH to point to $HOME/lib/python3.3. (Note: on Linux, amd64 you might need to link $HOME/.local/lib64 to $HOME/.local/lib.) It should be enough to add to your ~/.bashrc or ~/.profile the following snippet:

if [ -z ${PYTHONPATH} ];then
    export PYTHONPATH=$HOME/.local/lib/python3.3/site-packages/;
    export PYTHONPATH=$PYTHONPATH:$HOME/.local/lib/python3.3/site-pacakges/;

You can update a module with easy_install. The procedure is the same as to install it just run:

easy_install --prefix=$HOME/.local <module_name>

If you want to uninstall a module you need to use another program called pip. It something like your Linux package manager or MacPorts on MacOs. It is build upon easy_install. For example to install psutil module in ~/lib/python2.7 you just run:

pip install --install-option='--prefix=$HOME/.local' psutil

The --install-option switch passes the option to easy_install. To uninstall a module:

pip uninstall psutil

You can also search packages:

pip search psuti
psutil                    - A process and system utilities module for Python
procinfo                  - wrapper around psutil for ease of use
metlog-psutils            - PSUtils extensions to metrics logging

For more options see pip help. There are three ways how you can now obtain pip: you should first try your system tools (Linux, MacOs), or you can install it using easy_install:

easy_install --prefix=$HOME/.local pip

You can also get it from its page. The more thorough documentation you can find in this link.


The IPython program is a nice tool to use and learn Python. It is worth mentioning that IPython work both on Pyton2.7 and Python3.3 (Python3.2 or higher). It brings a very nice shell, which allows to write snippets of code in editor of choice, indent multiline code in the shell and it has an enhanced completion (under the Tab key) for modules, functions, classes and their methods. Using an external editor rather than just a command line which is quite helpful when writing a snippet of code which takes few lines, since command line will not give you the chance to change any previous line. It has many many more interesting features. It is available on Windows, MacOs and Linux. If you are on Linux you should use your distribution method to install it, on Windows and MacOs you can use easy_install program (easy_install.exe). Just open a command prompt (terminal) and type (you can add --prefix as discussed in the previous section):

easy_install.exe ipython

If you have not added easy_install.exe to the PATH variable, then you have to specify full path above. It is also good to install pyreadline module. It will add two nice features to IPython, color prompt (if you use a terminal which can handle colors, unfortunatelly command prompt on Windows does not) and more importantly tab completion for Python functions and keywords in IPython. This is really helpful and can make it easier to learn the language. On Linux pyreadline comes with Python so you do not need to make any further steps, on Windows and MacOs just type in the command prompt (terminal):

easy_install.exe pyreadline


On MacOs you can use the standard IDLE development environment. The instructions how to use it can be found here .

Python shell

If you are going to use Python shell from the terminal rather than a fully flagged IDLE environment you can configure the shell in a much nicer way. On some systems Python comes with GNU readline* library which have a GNU Bash shell like capabilities: Emacs and vi editing modes, history and completion. You can read here how to turn in on. There is a very nice startup script at the end of section 13.3.

Terminal on Windows

Since the Windows command prompt is not a very rich environment you can install a more developed product. There are a number of terminal emulators for Windows (see this list ). One which is free and just works is Console2 (this page also list a few other good solutions). Also note that if you just double click the Python executable python.exe it will open a Python console in the Window’s command prompt, but using a proper terminal emulator and IPython or and IDLE is preferred.

Last update: 2013-11-06 11:02 (CET)
Contact us.
Created using , and
we are not associated with Python Software Foundation
© Copyright 2012, 2013 Accorda Institute.