views:

212

answers:

2

I am reading the book Think Python by Allen Downey. For chapter 4, one has to use a suite of modules called Swampy. I have downloaded and installed it.

The problem is that the modules were written in Python 2 and I have Python 3 (in Windows 7 RC1). When I ran the TurtleWorld module from Swampy, I got error messages about the print and exec statements, which are now functions in Python 3. I fixed those errors by including parentheses with print and exec in the code of the GUI and World modules. I also got an error that the Tkinter module could not be found. It turned out that in Python 3, the module name is spelled with a lower case t.

The third error is more difficult: ImportError: No module named tkFont.

Does anyone have any idea, please? Thank you.

+1  A: 

Many important third-party libraries have not yet been rewritten for Python 3; you'll have to stick to Python 2.x for now. There is no way around it. As it says on the official Python download page,

If you don't know which version to use, start with Python 2.6.4; more existing third party software is compatible with Python 2 than Python 3 right now.

Jonathan Feinberg
This would be the simplest. Thanks. I will give the conversion tool suggested by Stephen Doyle a try first.
Geoffrey Van Wyk
A: 

There is a conversion tool for converting Python 2 code to work with Python 3: http://svn.python.org/view/sandbox/trunk/2to3/

Not sure how this extends to 3rd party libraries but it might be worth passing this over the swampy code.

Stephen Doyle
Thanks. I will give it a try.
Geoffrey Van Wyk