Configuring Python for Tk on Mac

Discussion in 'Python' started by Martyn Quick, Jan 21, 2005.

  1. Martyn Quick

    Martyn Quick Guest

    On my desk here at work I have a Mac G4 running Mac OS X v10.2.8.

    When I go into a terminal and type "python" up comes a nice python
    interface and all seems great. However when I type "import Tkinter"
    I'm greeted by the following error.

    >>> import Tkinter

    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 35, in ?
    import _tkinter # If this fails your Python may not be configured
    for Tk
    ImportError: No module named _tkinter

    So I guess something about this implementation is not appropriately
    configured. I'm guessing this is the default behaviour since I don't
    think anyone did anything special about python when they set up my
    machine.

    What do I do to set it up so I can use Tkinter?

    Thanks... and sorry if this is an FAQ... but I couldn't find the info
    easily.

    Yours,
    Martyn
    Martyn Quick, Jan 21, 2005
    #1
    1. Advertising

  2. Martyn Quick

    Matt Guest

    Matt, Jan 21, 2005
    #2
    1. Advertising

  3. Martyn Quick

    Craig Ringer Guest

    On Fri, 2005-01-21 at 07:39 -0800, Martyn Quick wrote:
    > On my desk here at work I have a Mac G4 running Mac OS X v10.2.8.
    >
    > When I go into a terminal and type "python" up comes a nice python
    > interface and all seems great. However when I type "import Tkinter"
    > I'm greeted by the following error.
    >
    > >>> import Tkinter

    > Traceback (most recent call last):
    > File "<stdin>", line 1, in ?
    > File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 35, in ?
    > import _tkinter # If this fails your Python may not be configured
    > for Tk
    > ImportError: No module named _tkinter
    >
    > So I guess something about this implementation is not appropriately
    > configured.


    In general, that error means that Python can't find the C extension
    module used to provide the low-level interface for Tkinter. It's not
    installed, can't be found (library path or python path issues), can't be
    opened (permissions), etc.

    Note the comment in the error message to that effect.

    I've just checked the OSX 10.3 machine here, and it fails to import
    tkinter there too. I'd say Apple just don't build Python with Tk
    support.

    > What do I do to set it up so I can use Tkinter?


    Try Google - this seems to be a moderately FAQ for MacOS/X.

    --
    Craig Ringer
    Craig Ringer, Jan 21, 2005
    #3
  4. Martyn Quick

    Jim Sizelove Guest

    Martyn Quick wrote:
    > On my desk here at work I have a Mac G4 running Mac OS X v10.2.8.
    >
    > When I go into a terminal and type "python" up comes a nice python
    > interface and all seems great. However when I type "import Tkinter"
    > I'm greeted by the following error.
    >
    >
    >>>>import Tkinter

    >
    > Traceback (most recent call last):
    > File "<stdin>", line 1, in ?
    > File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 35, in ?
    > import _tkinter # If this fails your Python may not be configured
    > for Tk
    > ImportError: No module named _tkinter
    >
    > So I guess something about this implementation is not appropriately
    > configured. I'm guessing this is the default behaviour since I don't
    > think anyone did anything special about python when they set up my
    > machine.
    >
    > What do I do to set it up so I can use Tkinter?
    >
    > Thanks... and sorry if this is an FAQ... but I couldn't find the info
    > easily.
    >
    > Yours,
    > Martyn



    You probably need to install Tcl/Tk Aqua:
    http://tcltkaqua.sourceforge.net

    After downloading and installing on my Mac running OS X v 10.2, I am
    able to open IDLE and other Tk apps.

    HTH,

    Jim Sizelove
    Jim Sizelove, Jan 21, 2005
    #4
  5. Craig Ringer <> wrote:
    ...
    > I've just checked the OSX 10.3 machine here, and it fails to import
    > tkinter there too. I'd say Apple just don't build Python with Tk
    > support.


    No idea about any 10.2, sorry, but on 10.3 that's not the problem: Tk
    support is there alright, it's Tcl/Tk which _isn't_. Get MacPython, its
    PackageManager will explain where to get Tcl/Tk Aqua from, as a prereq
    for Tkinter and IDLE!


    Alex
    Alex Martelli, Jan 21, 2005
    #5
  6. In article <>,
    (Martyn Quick) wrote:

    >On my desk here at work I have a Mac G4 running Mac OS X v10.2.8.
    >
    >When I go into a terminal and type "python" up comes a nice python
    >interface and all seems great. However when I type "import Tkinter"
    >I'm greeted by the following error....


    Assuming you are running MacPython from
    <http://homepages.cwi.nl/~jack/macpython/macpython-osx.html>...

    Install Aqua Tcl/Tk as another poster suggested.

    Run Applications/MacPython.../Package Manager and install Tkinter.

    Or if your MacPython is out of date, you may just want to download and
    install the current version. If Tcl/Tk is already installed then I think
    it will install Tkinter automatically (but if not, use Package Manager).

    If you are running some other python, please tell us more about it. (If
    it's fink python, install the version that includes Tkinter support, but
    this runs on X11 instead of Aqua).

    -- Russell
    Russell E. Owen, Jan 24, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jani Yusef
    Replies:
    4
    Views:
    499
    Jean-Yves Vinet
    Feb 5, 2004
  2. Robert Brewer
    Replies:
    1
    Views:
    621
    omission9
    Feb 5, 2004
  3. Robert Brewer
    Replies:
    1
    Views:
    390
    omission9
    Feb 6, 2004
  4. Martyn Quick
    Replies:
    1
    Views:
    295
    Kevin Walzer
    Jan 27, 2005
  5. K Richard Pixley
    Replies:
    3
    Views:
    341
    Ned Deily
    Jan 3, 2012
Loading...

Share This Page