Installing Python 3.1 from Source code on OS X with readline

So I recently took it apon myself to try installing Python 3.1 from source code on my Mac laptop.

As soon as ‘make’ had finished I was presented with a message telling me that several libraries which would be required for extra functionality were missing.

One of these was ‘readline’. If you don’t know what ‘readline’ does, it provides the functionality inside the Python interpreter similar to that in Bash or Doskey. Just to mention one of the small but important feature it allows you to be able to press the up and down arrow keys to scroll through previous input. If you intended on using the Python interpreter interactively this is pretty much an essential.

OS X does not contain the GNU readline library and instead uses a replacement called editline due to licencing issues.

It’s been a few days since I performed the install but I hope my memory serves me correctly in detailing the steps necessary to get Python compiled and using the readline library. Please leave comments to the contrary if you believe I’ve missed out any step and I will try to plug-in the blanks.

Please note, to compile programs from source on OS X you will need to install X Code from Apple. This is the Apple development environment which bundles their IDE, libraries and such along with the GNU C compiler GCC.

The first thing I needed to do was to download the ‘readline’ library. I did so by downloading readline-6.1.0.tar.gz from http://pypi.python.org/pypi/readline/.

Once downloaded and extracted, I opened up the terminal and navigated to the ‘~/readlin-6.1.0/readline/’ directory.

Here I ran the command ‘./configure’, this checks your environment for prerequisites required for the compilation and then configures the make file for the build as appropriate.

Once this has completed successfully, you should run now run the command ‘make’. Again this should be done from the terminal in the same directory as before. Your computer will now be compiling the ‘readline’ library.

Presuming all steps have been successful so far you can now type, ‘sudo make install’, again from the terminal in the same directory. You will require admin permissions for this due to files being copied to protected directories. You have now installed the ‘readline’ library we have just compiled.

Now that we have built and installed the library, you can go back to your Python source code folder and compile and install Python 3.1 as instructed in the Python documentation.

All going well, you will now notice that at the end of the compile it will no longer complain about ‘readline’ being missing and your Python interpreter, will now work as intended with the correct functionality.

Welcome to my blog

Welcome to my blog. I will be using this space to write about and catalog my musings on technology, software, music production, programming, Mac OS X, Linux, Windows and anything else which happens to take my fancy.

My hope is that my blogs may be helpful and informative to those following in similar footsteps. If I can help some save time in whatever task is at hand or help point in the direction of a reference which helped me in achieving said task then great.

Professionally I work as a network administrator for both Windows and OS X network environments in an academic setting.

At home and on the move I use my MacBook Pro running Snow Leopard (10.6.x) along with Debian and Windows virtual machines installed and running side-by-side.

I use Logic Studio 9 for my amateur music production.

I use a number of programming languages in my spare time and in an attempt to help automate tasks at work but I would not profess to be anything more than a keen amateur in any of them and I’m sure my code leaves much to be desired. Regardless of this, I will still try to blog about things I’ve learnt, references I’ve found, problems and solutions that I’ve stumble across in the hope that they may be useful to others like myself.

The languages I’m currently focussing on are Python 3.1 and Objective-C  / Cocoa.

I’ve also recently started to learn about electronics, having bought myself several beginners books on electronics and Arduino, a starters electronics kit and an Arduino Duemilanove, an open source programmable prototyping board with a AVR microprocessor which can be programmed via USB and a simple C-like language to interface with a number of electronic components. Most importantly about the Arduino is it’s cheap. My Arduino board costing a little under £20. Arduino seems to have a lively online community and I’m really excited about getting to grips with it and realising my ideas in hardware.

I aim to blog about things which I have done, or that I have found interesting across all the fields mentioned and in any other areas of my life which I feel compelled to write about. I’ll be doing this to catalogue my experiences for my own future reference, to help others with similar problems and to help proliferate the spread of knowledge in any small way I can.

If you’re wondering where the name for my blog comes from, it’s my surname written backwards. Nothing more mysterious than that I’m afraid.

J