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 [Sept. 2, 2012, 1:14 p.m.]


There are three 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 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. You will have to install any other required module as and when required. One way to do this is to use the pip command. It is also possible to use easy_install.

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 (Their website does list a Linux version but I can't find it, 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 can download 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 interactive or exploratory 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.

IDEs that fall in the first category are Geany (Windows and Linux), gedit or kate (Linux only), PyScripter (Windows only)   and WingIDE 101 (Windows and Linux). They are simple, fast and well suited for beginners.

IDEs that fall in the second category are Eclipse with PyDev, Aptana, Wing IDE, PyCharm (non-free, 30-day free trial). They are feature-rich and extremely capable but not suited for beginner.

If you care for a suggestion, I would recommend using Geany or PyScripter (WIndows only) or gedit or kate (Linux only) because it is open source, light, simple and fast. But is available only on Windows. On GNU/Linux and also on Windows, Wing IDE 101 (free of cost software) is quite good. Editra is multi-platform, open source, light,simple and fast.

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 type 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 or more 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.

Watch this screencast on YouTube