[Tutor] Correct Path for tkinter using python3.1 on Ubuntu Maverick!!

Nevins Duret duretn at bellsouth.net
Wed Jan 19 22:21:22 CET 2011


Hello Python Collective,

    Well, I'm sure this topic came up before on this forum, and I was
confident that I mastered it having had to set it up correctly on my Mac
systems and linux systems in the path.  Here are my findings.  I am
trying to run this code:

#!/usr/bin/env python3.1

from tkinter import label
widget = Label( None, text = 'Hello Gui World' )
widget.pack()
widget.mainloop()


--in order to do several tkinter tutorials that I am following in a book
and I keep getting this error:


Traceback (most recent call last):
  File "/home/myhomename/pythonproj/hellogui2.py", line 3, in <module>
    import messagebox
ImportError: No module named messagebox


First off, I checked my path, and in having checked several on-line
tutorials on how to set up the tkinter module, one of them made mention
that the lib-tk folder is no longer available in python3.1 and that this
should be the correct path on Linux systems:

/usr/lib/python3.1/tkinter

, which when I looked inside this directory, I did manage to find the
files messagebox.py and messagebox.pyc. I also wen to this link:

 http://wiki.python.org/moin/TkInter

and ran python3.1 in my Terminal:

>>>import _tkinter # with underscore, and lowercase 't'

>>>import Tkinter # no underscore, uppercase 'T' prior to V3.0;
lowercase 't' from v3.0

>>>Tkinter._test() # note underscore in _test.  Also, if you are using
Python 3.1, try tkinter._test() instead

The first line ran ok, but in order to get the second and third line to
work I had to change them to( making Tkinter lower case tkinter:


>>>import tkinter # no underscore, uppercase 'T' prior to V3.0;
lowercase 't' from v3.0

>>>tkinter._test() # note underscore in _test.  Also, if you are using
Python 3.1, try tkinter._test() instead


Is this because my path is still missing some essential module, or does
it have to do with the fact that its deprecated in 3.1?  Again, I've
made sure that my .bashrc file contains export PYTHONPATH
= /usr/lib/python3.1/tkinter.  Is there anything else that I'm to do?
Any help would be greatly appreciated.

Best Regards,

freesparks






More information about the Tutor mailing list