The Python installation is quick and painless on both Linux and Windows. Windows users are blessed with an installer that takes care of all of the setup for you; however, on Linux you will be building the installation from source code.
Windows users can obtain the installer from the main Python site: http://python.org/ftp/python/2.5.1/python-2.5.1.msi. Just double-click the installer, and follow the steps to install it. It should create a directory at C:/Python25/; this directory will have the python.exe interpreter as well as all of the default libraries installed.
You can optionally install Immunity Debugger, which contains not only the debugger itself but also an installer for Python 2.5. In later chapters you will be using Immunity Debugger for many tasks, so you are welcome to kill two birds with one installer here. To download and install Immunity Debugger, visit http://debugger.immunityinc.com/.
To install Python 2.5 for Linux, you will be downloading and compiling from source. This gives you full control over the installation while preserving the existing Python installation that is present on a Red Hat–based system. The installation assumes that you will be executing all of the following commands as the root user.
The first step is to download and unzip the Python 2.5 source code. In a command-line terminal session, enter the following:
#cd /usr/local/
#wget http://python.org/ftp/python/2.5.1/Python-2.5.1.tgz
#tar -zxvf Python-2.5.1.tgz
#mv Python-2.5.1 Python25
#cd Python25
You have now downloaded and unzipped the source code into /usr/local/Python25. The next step is to compile the source code and make sure the Python interpreter works:
#./configure --prefix=/usr/local/Python25
#make && make install
#pwd
/usr/local/Python25
#python
Python 2.5.1 (r251:54863, Mar 14 2012, 07:39:18) [GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on Linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
You are now inside the Python interactive shell, which provides full access to the Python interpreter and any included libraries. A quick test will show that it's correctly interpreting commands:
>>> print "Hello World!"
Hello World!>>> exit()
#
Excellent! Everything is working the way you need it to. To ensure that your user environment knows where to find the Python interpreter automatically, you must edit the /root/.bashrc file. I personally use nano to do all of my text editing, but feel free to use whatever editor you are comfortable with. Open the /root/.bashrc file, and at the bottom of the file add the following line:
export PATH=/usr/local/Python25/:$PATH
This line tells the Linux environment that the root user can
access the Python interpreter without having to use its full path. If
you log out and log back in as root, when you type
python
at any point in your command shell you will
be prompted by the Python interpreter.
Now that you have a fully operational Python interpreter on both Windows and Linux, it's time to set up your integrated development environment (IDE). If you have an IDE that you are already comfortable with, you can skip the next section.