Like most mechanical engineering students I know, I have a love-hate relationship with MATLAB. Most of the time, it’s great, but it is not free and running it through a network (like BYU does on all of its computers) can be a huge pain. As an alternative, I’ve decided to switch to Python, which is free and completely cross-platform. I haven’t done a whole lot in it yet, but I’ve heard you have a little more control over how your graphs look in Python as well.
Installation – Windows
For Windows users, there is a nice package called Python(x,y) that pretty much installs everything for you, including both the Spyder IDE and Eclipse. I haven’t used Eclipse yet, but I’ve found Spyder to be a very nice alternative to MATLAB. To install, just go to http://www.pythonxy.com/ and download the Windows Installer package.
Installation – Ubuntu Linux
Part of the beauty of switching to Python is how cross-platform it is. While pythonxy hasn’t finished a linux build yet, installing spyder is pretty easy in ubuntu:
sudo apt-get install python-sphinx python-scipy python-matplotlib spyder
Note: All you really need is spyder, but adding python-sphinx allows you to have rich text in your documentation which looks nice and in my opinion is easier to read. The packages python-scipy and python-matplotlib may be optional, but I use them in my tutorials, so I would recommend including those as well.
Installation – Gentoo Linux
Unfortunately, python(x,y) doesn’t have a convenient ebuild for Gentoo Linux, but here’s how to get a similar setup up and running in Gentoo:
install the base libraries and such that you will need:
emerge -av numpy scipy matplotlib ipython
For my Gentoo installation, the Spyder IDE unfortunately does not work (for one thing, it’s Qt, not GTK, so it looks ugly on my desktop. For another, it occasionally crashes my entire desktop, which is a little less forgiveable, you can install it at your own risk if you unmask it, but I recommend an alternative IDE)
Option 1: PythonToolkit (http://pythontoolkit.sourceforge.net/)
emerge -av wxpython
download and unzip the source .zip
python setup.py install
It didn’t automatically create a start menu entry, but you can now run PTK to fire up the IDE.
Option 2: Eclipse
emerge -av eclipse-sdk
Once Eclipse has installed, follow the instructions on the PyDev page to enable the Python IDE in Eclipse
I haven’t fooled around with it too much, but it looks pretty nice:
Mac OS X Installation
I don’t own a Mac, and never will, but for completeness, I thought I’d include some links for how to get set up in OS X. Python stuff is generally pretty cross-platform, so in OS X you still have the choice between Spyder, PTK, and Eclipse. I’ve found Eclipse to be bloated, slow, and incomplete for what I want to do, so I’ll only include instructions for Spyder and PTK, especially since they have similar dependencies.
If I’m not mistaken, Mac OS X already comes with Python installed, but the Numpy site claims their binaries only work with the official version, Apple must have corrupted their default. Before proceeding, you may want to look at this link for some alternatives. I would recommend to go ahead and grab the official version at python.org . Choose the appropriate binary for Python 2.x (last I checked, it was 2.7.1).
For PTK, the only other dependencies you need are:
- WxPython (Necessary for the GUI)
- Numpy (Array handling in Python)
- Scipy (More useful scientific functions for Python)
- Matplotlib (A MATLAB-like plotting interface)
After that, download the latest stable version of PTK here.
For Spyder, you will additionally want these dependencies:
- pyflakes (real-time error checking, gives you fuzzy spell-check-esque lines when you have bad syntax)
- rope (code completion, etc.)
- sphinx (make code documentation pretty with rich text format)
- iPython (a more advanced interactive terminal)
My Two Cents
After about a month of Python programming, I really like both Spyder and PTK. Spyder is pretty big, with a lot of fancy features that also make it take a while to load, I would definitely not recommend it for slower machines or if you don’t have much RAM. PTK, on the other hand, is super-light and super-fast. It lacks a lot of Spyder’s fancier features, like auto-completion, pretty documentation formatting, and live syntax checking, but it has all the essentials and I really like it.