Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 18th, 2005, 09:30 PM
Martyn Quick
Guest
 
Posts: n/a
Default Configuring Python for Tk on Mac

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.
[color=blue][color=green][color=darkred]
>>> import Tkinter[/color][/color][/color]
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
  #2  
Old July 18th, 2005, 09:31 PM
Matt
Guest
 
Posts: n/a
Default Re: Configuring Python for Tk on Mac

I googled around and it looks like it might be a permissions error:
http://mail.python.org/pipermail/pyt...er/006809.html
I don't have a Mac, tho', so I have no idea if it works...
HTH

  #3  
Old July 18th, 2005, 09:31 PM
Craig Ringer
Guest
 
Posts: n/a
Default Re: Configuring Python for Tk on Mac

On Fri, 2005-01-21 at 07:39 -0800, Martyn Quick wrote:[color=blue]
> 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.
>[color=green][color=darkred]
> >>> import Tkinter[/color][/color]
> 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.[/color]

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.
[color=blue]
> What do I do to set it up so I can use Tkinter?[/color]

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

--
Craig Ringer

  #4  
Old July 18th, 2005, 09:31 PM
Jim Sizelove
Guest
 
Posts: n/a
Default Re: Configuring Python for Tk on Mac

Martyn Quick wrote:[color=blue]
> 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.
>
>[color=green][color=darkred]
>>>>import Tkinter[/color][/color]
>
> 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[/color]


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
  #5  
Old July 18th, 2005, 09:31 PM
Alex Martelli
Guest
 
Posts: n/a
Default Re: Configuring Python for Tk on Mac

Craig Ringer <craig@postnewspapers.com.au> wrote:
...[color=blue]
> 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.[/color]

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
  #6  
Old July 18th, 2005, 09:37 PM
Russell E. Owen
Guest
 
Posts: n/a
Default Re: Configuring Python for Tk on Mac

In article <d1134b83.0501210739.688ca731@posting.google.com >,
martyn_quick@yahoo.co.uk (Martyn Quick) wrote:
[color=blue]
>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....[/color]

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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles