[Tutor] problem adding Tkinter

Kristin Wilcox wilcoxwork at gmail.com
Sat Oct 31 01:21:15 CET 2009


I apologize in advance for asking such a simple question! I first
tried looking through Google, and through the last couple months of
this list's archives, and I found some talk about my issue out there
but not a detailed enough answer to help someone as new as me.

This is my first programming language, so most explanations of this
stuff go way over my head!

[This is my problem:] I've been using IDLE successfully to do very
very simple exercises in Python, and now I wanted to start on some
very simple exercises including the Tkinter library. But it looks like
it's not set up right and I don't know how to do what I need to do to
adjust.. whatever needs to be adjusted.

I did the tests listed here: http://wiki.python.org/moin/TkInter

I failed at step 2:
-----
Step 2 - can Tkinter be imported?

Try the following command at the Python prompt:

>>> import Tkinter # no underscore, uppercase 'T'

    * If it works, go to step 3.
    * If it fails with "No module named Tkinter", your Python
configuration need to be changed to include the directory that
contains Tkinter.py in its default module search path. You have
probably forgotten to define TKPATH in the Modules/Setup file. A
temporary workaround would be to find that directory and add it to
your PYTHONPATH environment variable. It is the subdirectory named
"lib-tk" of the Python library directory (when using Python 1.4 or
before, it is named "tkinter").
------
I could do import _tkinter but not import Tkinter

This is what I received back from the Shell:
>>> import _tkinter
>>> import Tkinter
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import Tkinter
ImportError: No module named Tkinter
>>>


Unfortunately, the instructions they gave on what to do if Step 2
fails read like Greek to me. I don't know what a PYTHONPATH is, I
don't remember doing anything with a Modules/Setup file, and I don't
know what an environment variable is, or what to do with
subdirectories.

I am running Windows XP. Installed Python 3.1, and IDLE seems to be
working okay...

When I go to C:\Python31 I see these folders:
DLLs
Doc
include
Lib
libs
tcl
Tools

There are 3 .exe files:
python.exe
pythonw.exe
w9xpopen.exe

I see something called _tkinter.lib in the folder C:\Python31\libs
There is a folder called tkinter inside the folder Lib (C:\Python31\Lib\tkinter)

Would someone be able to spell out to me in every detailed steps
exactly what I should do, assuming I know pretty much nothing about
programming or installing a programming language, so that when I put
import Tkinter it doesn't error?

Thank you very much for reading!

-Kristin


More information about the Tutor mailing list