You can obtain the Python Standard Library from a number of sources, but the best place to go is directly to the Python Web site at http://www.python.org/download/. Download the Python 2.6.4 Windows installer version of the product (about 14.2 MB). IronPython won’t currently work with the newer 3.1.1 version of Python (nor will many third-party libraries). After you complete the download, you’ll have a file named python-2.6.4.msi. The following steps tell how to install the product on your machine.
- Right-click the file and choose Install from the context menu. You’ll see a Welcome page like the one shown in Figure 6-1 that asks whether you want to install Python for all users or just for your own needs. Notice that you can’t perform a personal installation on Windows Vista — it really doesn’t work.
- Choose an installation option (either will work for the book) and click Next. The installer will ask where you want to install Python. In most cases, the installer will choose C:Python26, which works out well for using the Standard Library from IronPython. As an alternative, you could install Python in a directory below the IronPython directory, but the default usually works fine.
- Choose an installation location and click Next. You’ll see the Customize Python 2.6.4 dialog box shown in Figure 6-2. Notice the Register Extensions entry. If you let the installer make this change, Python, not IronPython, will be the default installation.
- Click the down arrow in the Register Extensions option and choose Entire Feature Will Be Unavailable from the menu. You can choose to keep all of the remaining features if desired (highly recommended).
- Configure any of the other installation options as needed. Click Next. You’ll see a status dialog box as Python installs to your hard drive. Eventually, you see a completion dialog box.
- Click Finish. Python (and its associated Standard Library) is set up on your machine.
C Modules in the Python Standard Library
One of the reasons that IronPython installs a tuned version of the Standard Library is that the full Standard Library has modules written in C included with it. These modules generally won’t work with IronPython. As Python has become more advanced, the developers have removed many of these C modules and you may eventually find that they’re all gone.
Of course, you might find that you really do need that C module because nothing else will work. In this case, you can try to gain access to the C module using IronClad (http://code.google.com/p/ironclad/). You won’t always have complete success using IronClad, but it does help considerably, and you should give it a try for those stubborn modules.
Another potential fix is getting a pure Python version of the module you need from PyPy (http://codespeak.net/pypy/dist/pypy/doc/). In many cases, the PyPy solution is actually a little more compatible than other solutions because it does rely on pure Python code to provide access to the module you want. A potential disadvantage of this solution is that the pure Python alternatives will tend to run slower than the C modules they replace.
Finally, there’s the IronPython Community Edition (also known as FePy) (http:// fepy.sourceforge.net/). This group has created solutions for the C modules based on the .NET Framework. From an IronPython perspective, this solution is probably the most compatible option. However, in using the .NET Framework, you potentially give up some cross-platform independence. Fortunately, the IronPython Community Edition also has information on using its version of IronPython with Mono (http://mono-project.com/Main_Page), which lets .NET applications run on both Linux and Macintosh systems.