This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Setting Up a Scientific Python Environment [March 2, 2012, 6:47 a.m.]


There are two aspects to consider when deciding upon a working environment for scientific Python:

  1. Operating System
  2. Python distribution
  3. Integrated Development Environment (IDE)


Operating System: Python is free, open source and multi-platform. Therefore you could choose any operating system on which Python is available. That includes all the major operating systems - Microsoft Windows, GNU/Linux, Mac OS X.

Python Distribution: You have two choices.

The first is to use the standard Python distribution from http://www.python.org with additional modules required for scientific computing, namely, NumPy, SciPy and Matplotlib.

The second choice is to download a  single distribution suited for scientific Python. Your choices are Enthought Python Distribution (EPD) which is available for Windows,GNU/Linux and Mac OS X for both 32 and 64 bit versions. The other is Python(x,y) which is available only for Windows (as far as I know,correct me if I am wrong) and only the 32-bit version.

First requires you to identify and download each module you may need, but you candownload only the ones you need. Second gives you all modules you may possibly need,even the ones you may never use. The choice is entirely personal.

Integrated Development Environment: We will begin using Python interactively in IPython. But pretty soon, we will have to begin writing code in an editor. That is when an IDE becomes necessary. IPython with the --pylab switch, is tailor made for scientific computing and is simple yet powerful. However, what it cannot do is write, edit and save code.

IDEs for Python can be very simple (suited for beginners) or fairly complex (suited for serious developers). The choice is wide. Eclipse with PyDev, Aptana, Wing IDE, PyCharm, PyScripter (Windows only). If you care for a suggestion, I would recommend using PyScripter on WIndows because it is light, simple and fast. On GNU/Linux and also on Windows, Wing IDE 101 (free of cost software) is quite good.

So, the first task is to download and install Python family of software for scientific computing and an IDE of your choice. Once you have installed Python, IPython, NumPy, SciPy and Matplotlib, test if they are installed correctly. Open IPython and try the following at the IPython prompt:

[In [1] import numpy
[In 2] import scipy
[In 3] import matplotlib

If you see error messages, you are missing one of the required modules. Otherwise, you are all set to start.

To exit IPython press Ctrl+D on the keyboard and answer yes when asked to confirm whether you want to exit or type the command exit at the prompt.